![]() |
Home | Libraries | People | FAQ | More |
Notation
Synthesized attribute. The rule or grammar's return type.
Inherited attributes. Zero or more or arguments.
Zero or more local variables.
Rules
A grammar
A parser expression
A user defined grammar
Terminology
RT(Arg1, Arg2 ... ,ArgN). The signature specifies the synthesized (return value) and inherited (arguments) attributes.
locals<L1, L2 ..., LN>. The local variables.
The skip-parser type
Template Arguments
The iterator type you will use for parsing.
Can be one of 1)Signature 2)Locals 3)Skipper.
Expression |
Description |
---|---|
rule<Iterator, A1, A2, A3> r(name); |
Rule declaration. Iterator is required. A1, A2, A3 are optional and can be specified in any order. name is an optional string that gives the rule its name, useful for debugging and error handling. |
rule<Iterator, A1, A2, A3> r(r2); |
Copy construct rule r from rule r2. boost::shared_ptr semantics. |
r = r2; |
Assign rule r2 to r. boost::shared_ptr semantics. |
r.alias() |
return an alias of r. The alias is a parser that holds a reference to r. Reference semantics. |
r.copy() |
Get a copy of r. boost::shared_ptr semantics. |
r.name(name) |
Naming a rule |
r.name() |
Getting the name of a rule |
debug(r) |
Debug rule r |
r = p; |
Rule definition |
r %= p; |
Auto-rule definition. The attribute of p should be compatible with the synthesized attribute of r. When p is successful, its attribute is automatically propagated to r's synthesized attribute. |
template <typename Iterator> struct my_grammar : grammar<Iterator, A1, A2, A3> { my_grammar() : my_grammar::base_type(start, name) { // Rule definitions start = /* ... */; } rule<Iterator, A1, A2, A3> start; // more rule declarations... };
|
Grammar definition. name is an optional string that gives the grammar its name, useful for debugging and error handling. |
my_grammar<Iterator> g |
Instantiating a grammar |
g.name(name) |
Naming a grammar |
g.name() |
Getting the name of a grammar |