...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Notation
RT
Synthesized attribute. The rule or grammar's return type.
Arg1
, Arg2
, ArgN
Inherited attributes. Zero or more arguments.
L1
, L2
, LN
Zero or more local variables.
r,
r2
Rules
g
A grammar
p
A parser expression
my_grammar
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
Iterator
The iterator type you will use for parsing.
A1
, A2
, A3
Can be one of 1) Signature 2) Locals 3) Skipper.
Expression |
Description |
---|---|
|
Rule declaration. |
|
Copy construct rule |
|
Assign rule |
|
return an alias of |
|
Get a copy of |
|
Naming a rule |
|
Getting the name of a rule |
debug(r) |
Debug rule |
|
Rule definition |
|
Auto-rule definition. The attribute of |
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. |
|
Naming a grammar |
|
Getting the name of a grammar |