![]() |
Lumiera 0.pre.04
»edit your freedom«
|
#include "lib/parse.hpp"
A Syntax clause with a parser and result state.
An instance of this class embodies a (possibly complex) expected syntactical structure; the parse function analyses a given input text for compliance with this expected structure. After the parse, result state has been set
Public Types | |
| using | Connex = PAR::Connex |
| using | Result = PAR::Result |
Public Types inherited from Eval< PAR::Result > | |
| using | Result = PAR::Result |
Public Member Functions | |
| Syntax () | |
| Syntax (PAR &&parser) | |
| operator bool () const | |
| operator Connex & () | |
| operator Connex const & () const | |
| bool | success () const |
| bool | hasResult () const |
| bool | canInvoke () const |
| size_t | consumed () const |
| Result & | getResult () |
| Result && | extractResult () |
| Syntax && | parse (StrView toParse) |
| Core API : parse against this syntax clause. | |
| template<class PX > | |
| Syntax & | operator= (Syntax< PX > refSyntax) |
| template<typename SPEC > | |
| auto | seq (SPEC &&clauseDef) |
| ===== Syntax clause builder DSL ===== | |
| template<typename SPEC > | |
| auto | alt (SPEC &&clauseDef) |
| Combinator: extend this Syntax by adding an alternative branch. | |
| template<typename SPEC > | |
| auto | opt (SPEC &&clauseDef) |
| Combinator: extend this Syntax with a further sequenced sub-clause, which however is only optional and the match succeed without it. | |
| template<typename SPEC1 , typename SPEC2 > | |
| auto | repeat (uint min, uint max, SPEC1 &&delimDef, SPEC2 &&clauseDef) |
| Combinator: extend this Syntax with a further sequenced sub-clause, which in this case accepts a repeated sequence, with delimiter. | |
| template<typename SPEC1 , typename SPEC2 > | |
| auto | repeat (uint cnt, SPEC1 &&delimDef, SPEC2 &&clauseDef) |
| template<typename SPEC1 , typename SPEC2 > | |
| auto | repeat (SPEC1 &&delimDef, SPEC2 &&clauseDef) |
| template<typename SPEC > | |
| auto | repeat (SPEC &&clauseDef) |
| template<typename SPEC1 , typename SPEC2 , typename SPEC3 > | |
| auto | bracket (SPEC1 &&openDef, SPEC2 &&closeDef, SPEC3 &&bodyDef) |
| Combinator: extend this Syntax with a further sequenced sub-clause in brackets. | |
| template<typename SPEC > | |
| auto | bracket (string bracketSpec, SPEC &&bodyDef) |
| template<typename SPEC > | |
| auto | bracket (SPEC &&bodyDef) |
| template<typename SPEC > | |
| auto | bracketOpt (string bracketSpec, SPEC &&bodyDef) |
| template<typename SPEC > | |
| auto | bracketOpt (SPEC &&bodyDef) |
| template<class FUN > | |
| auto | bind (FUN &&modelAdapt) |
| auto | bindMatch (uint group=0) |
Private Member Functions | |
| Eval< Result > & | eval () |
Private Attributes | |
| PAR | parse_ |
Additional Inherited Members | |
Public Attributes inherited from Eval< PAR::Result > | |
| optional< PAR::Result > | result |
| size_t | consumed |
|
inlineexplicit |
|
inlineexplicit |
Definition at line 801 of file parse.hpp.
References Syntax< PAR >::success().
Here is the call graph for this function:
|
inline |
Definition at line 803 of file parse.hpp.
References Syntax< PAR >::parse_.
|
inline |
Definition at line 804 of file parse.hpp.
References Syntax< PAR >::parse_.
|
inline |
Definition at line 806 of file parse.hpp.
Referenced by Syntax< PAR >::operator bool().
Here is the caller graph for this function:
|
inline |
Definition at line 808 of file parse.hpp.
References Syntax< PAR >::parse_.
|
inline |
Definition at line 810 of file parse.hpp.
Referenced by Syntax< PAR >::extractResult().
Here is the caller graph for this function:
|
inline |
Definition at line 811 of file parse.hpp.
References Syntax< PAR >::getResult().
Here is the call graph for this function:Core API : parse against this syntax clause.
Definition at line 818 of file parse.hpp.
References Syntax< PAR >::eval(), and Syntax< PAR >::parse_.
Referenced by util::parse::buildConnex(), and Syntax< PAR >::operator=().
Here is the call graph for this function:
Here is the caller graph for this function:Definition at line 827 of file parse.hpp.
References Syntax< PAR >::parse(), and Syntax< PAR >::parse_.
Here is the call graph for this function:
|
inline |
===== Syntax clause builder DSL =====
Combinator: extend this Syntax clause by expecting a further sub-clause behind the part of the input matched by the already defined part of this Syntax.
The result model will be a SeqModel, which essentially is a tuple of the result models of all sequenced parts.
Definition at line 1074 of file parse.hpp.
References util::parse::accept(), and util::parse::sequenceConnex().
Here is the call graph for this function:
|
inline |
Combinator: extend this Syntax by adding an alternative branch.
So either the already defined part of this Syntax matches the input, or the alternative clause is probed from the start of the input. At least one branch must match for the parse to be successful; however, further branches are not tested after finding a matching branch (short-circuit). The result model is a Sum Type, implemented as a custom variant record of type SubModel. It provides a branch selector field to detect which branch of the syntax did match. And it allows to retrieve the result model of this successful branch — which however requires that the invoking code precisely knows the model type to expect.
Definition at line 1096 of file parse.hpp.
References util::parse::accept(), and util::parse::branchedConnex().
Here is the call graph for this function:
|
inline |
Combinator: extend this Syntax with a further sequenced sub-clause, which however is only optional and the match succeed without it.
The result model is (as always for seq ) a tuple; the result from the optional part is packaged into a std::optional.
Definition at line 1112 of file parse.hpp.
References util::parse::accept_opt().
Here is the call graph for this function:
|
inline |
Combinator: extend this Syntax with a further sequenced sub-clause, which in this case accepts a repeated sequence, with delimiter.
Definition at line 1125 of file parse.hpp.
References util::parse::accept_repeated(), util::max(), and util::min().
Here is the call graph for this function:
|
inline |
Definition at line 1135 of file parse.hpp.
References util::parse::accept_repeated().
Here is the call graph for this function:
|
inline |
Definition at line 1145 of file parse.hpp.
References util::parse::accept_repeated().
Here is the call graph for this function:
|
inline |
Definition at line 1154 of file parse.hpp.
References util::parse::accept_repeated().
Here is the call graph for this function:
|
inline |
Combinator: extend this Syntax with a further sequenced sub-clause in brackets.
Definition at line 1166 of file parse.hpp.
References util::parse::accept_bracket().
Here is the call graph for this function:
|
inline |
Definition at line 1176 of file parse.hpp.
References util::parse::accept_bracket().
Here is the call graph for this function:
|
inline |
Definition at line 1185 of file parse.hpp.
References util::parse::accept_bracket().
Here is the call graph for this function:
|
inline |
Definition at line 1193 of file parse.hpp.
References util::parse::accept_bracketOpt().
Here is the call graph for this function:
|
inline |
Definition at line 1202 of file parse.hpp.
References util::parse::accept_bracketOpt().
Here is the call graph for this function:
|
inline |
Definition at line 1210 of file parse.hpp.
References util::parse::accept(), and util::parse::adaptConnex().
Here is the call graph for this function:
|
inline |
Definition at line 1219 of file parse.hpp.
References util::parse::accept(), and util::parse::toStringConnex().
Here is the call graph for this function:Definition at line 880 of file parse.hpp.
Referenced by Syntax< PAR >::parse().
Here is the caller graph for this function:
|
private |
Definition at line 785 of file parse.hpp.
Referenced by Syntax< PAR >::canInvoke(), Syntax< PAR >::operator Connex &(), Syntax< PAR >::operator Connex const &(), Syntax< PAR >::operator=(), and Syntax< PAR >::parse().
Inheritance diagram for Syntax< PAR >:
Collaboration diagram for Syntax< PAR >: