25 using pegmatite::Rule;
26 using pegmatite::operator
""_E;
27 using pegmatite::ExprPtr;
28 using pegmatite::BindAST;
46 (*(!ExprPtr(
'"'_E) >> (nl(
'\n') | any()))) >>
79 Rule
op =
'+'_E |
'=' |
'-' |
'*' |
'/' |
"min" |
"max";
94 Rule
range = literal | (
'('_E >> literal >>
',' >> literal >>
')');
141 #define CONNECT(cls, r) BindAST<AST::cls> r = CellAtomGrammar::get().r
142 CONNECT(StatementList, statements);
143 CONNECT(Literal, literal);
145 CONNECT(VRegister, v_reg);
146 CONNECT(LocalRegister, local_reg);
147 CONNECT(GlobalRegister, global_reg);
148 CONNECT(Arithmetic, arithmetic);
149 CONNECT(Range, range_expr);
150 CONNECT(RangeExpr, range_map);
151 CONNECT(Neighbours, neighbours);
Rule range_expr
A single entry in a range map: the source range and the target expression.
Singleton class encapsulating the grammar for the CellAtom language.
Rule v_reg
The current-value register v.
Rule statements
List of zero or more statements.
Class representing a parser for the CellAtom language.
static const CellAtomGrammar & get()
Returns a singleton instance of this grammar.
Rule neighbours
Neighbours expressions are simple a keyword and then a statement list in brackets.
Rule comment
Comments, including tracking newlines inside comments via the whitespace rule.
Rule local_reg
Local registers, l0 to l9.
Rule ignored
Rule for treating both comments and whitespace as ignored tokens.
Rule statement
Valid statements in this language are the arithmetic statements or neighbours statements.
Rule expression
Valid expressions in this language are.
Rule literal
Literal values are one or more digits.
Rule arithmetic
Arithmetic statements are an operation, a target register, and an expression.
Rule op
Operation keywords.
Rule digit
Decimal digits.
Rule range_map
A range map, evaluating to a different expression depending on the value in the register argument...
Rule range
The range part of a range expression (either a single value or an inclusive range).
Rule global_reg
Global registers, g0 to g9.
Rule whitespace
Whitespace: spaces, tabs, newlines.