entrypoints Grammars;

Grammars. Grammars ::= [Grammar];

Grammar. Grammar ::= "grammar" Ident [Flag] [Rule] "end" "grammar";
separator Grammar "";

StartCat. Flag ::= "startcat" Category;
terminator Flag ";";

Rule. Rule ::= Ident ":" Name Profile "." Category "->" [Symbol];
terminator Rule ";";

Profile. Profile ::= "[" [Ints] "]";

Ints. Ints ::= "[" [Integer] "]";
separator Ints ",";
separator Integer ",";

CatS. Symbol ::= Category;
TermS. Symbol ::= String;

-- separator Symbol "";
[]. [Symbol] ::= "." ;
(:[]). [Symbol] ::= Symbol ;
(:). [Symbol] ::= Symbol [Symbol] ;

Name. Name ::= SingleQuoteString ;
Category. Category ::= SingleQuoteString ;

token SingleQuoteString '\'' ((char - ["'\\"]) | ('\\' ["'\\"]))* '\'' ;
