Allow rule terms to be marked as optional

This commit is contained in:
josh committed 2024-05-09 11:56:13 -04:00
1 parent 494afb7307
commit f3e4941ad8
14 files changed
+346 -5

No files matched your search

+14
View File
@@ -631,6 +631,20 @@ This example uses the default start rule name of `Start`.
A parser rule has zero or more terms on the right side of its definition.
Each of these terms is either a token name or a rule name.
A term can be immediately followed by a `?` character to signify that it is
optional.
Another example:
```
token public;
token private;
token int;
token ident /[a-zA-Z_][a-zA-Z_0-9]*/;
token semicolon /;/;
IntegerDeclaration -> Visibility? int ident semicolon;
Visibility -> public;
Visibility -> private;
```
In a parser rule code block, parser values for the right side terms are
accessible as `$1` for the first term's parser value, `$2` for the second