Debian Codegraph @

example/usercontext/example.bnf

raw
1 !whitespace : ' ' | '\r' '\n' | '\n' ;
2
3 lowercase : 'a'-'z' { 'a'-'z' };
4
5 capitalized : 'A'-'Z' { 'a'-'z' | 'A'-'Z' };
6
7 << import "github.com/goccmack/gocc/example/usercontext/ast" >>
8
9 // This grammar supports some random number of identifiers (1,N),
10 // and must be ended with the literal "...42..."
11
12 Grammar
13 : Words "...42..." << $0, nil >>
14 ;
15
16 // Capitalized words get no special treatment, lowercase words invoke an ast function
17 // that expects a valid ParserContext.
18 Words
19 : capitalized
20 | Words capitalized
21 | lowercase << ast.NewIdentifier($0, $Context) >>
22 | Words lowercase << ast.NewIdentifier($1, $Context) >>
23 ;
24