Skip to content

Add documentation: Infix Operator Rules #283

@Lotes

Description

@Lotes

To improve readability of grammars, adopters can now use the new infix rule notation (#1836) to declare parsing rules used for infix operator parsing:

infix BinaryExpression on PrimaryExpression:
    '%' // <-- Highest precedence
    > '^'
    > '*' | '/'
    > '+' | '-';  // <-- Lowest precedence

PrimaryExpression infers Expression:
    '(' Expression ')' |
    {infer NumberLiteral} value=NUMBER;

Note that the previous tree-rewriting action based grammar is still (and always will be) supported.
In addition to better readability, the new notation also makes use of performance optimizations to speed up expression parsing by roughly 50% compared to the typical way of writing expressions.

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions