Irony - Language Implementation Kit/Grammar/Non Terminals

Rules
Rules tell the parser how to group the tokens fed to it by the scanner into expressions and statements.

The "+" and "|" have been overloaded so you can string terminals and non terminals together to define these rules.

From the ExpressionEvaluatorGrammar example found in the Irony project:

Kleene Operators
In traditional BNF notation, the "?", "+", and "*" characters are used to indicate "0 or 1 time", "1 or more times" and "0 or more times", respectively. In Irony, it's done slightly differently. You use the /MakePlusRule/ and /MakeStarRule/ methods from the base Grammar class for "+" and "*" or you can use the Q, Plus, and Star methods directly on the term within the rule.

A lot of languages will start with a non terminal called "program" which consists of one or more "statement" non terminals. The following is how you would indicate that:

Important note: when using /MakePlusRule/ or /MakeStarRule/, you cannot have anything else in the rule.

Hints
PreferShiftHere ReduceHere ResolveInCode ImplyPrecedenceHere

Transients
Transients are those non terminals that are used by the parser to break down statements into finer and finer expressions, but otherwise are not needed. For example, if you have a non terminal called "expression" that can break down into something more granular like "binaryExpression", then usually all you care about is that it was finally identified as a "binaryExpression". Putting "expression" into the parse tree just creates an extra node that doesn't really need to be there.

You can indicate which non terminals are transient using the MarkTransient method from the base Grammar class:

You cannot mark transient any non terminal whose AST node is of type StatementListNode. Therefore, non terminals like "program" cannot be marked transient as its definition is a list of statements.