entrypoints Grammars;

Grammars. Grammars ::= [Grammar];

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

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

Rule. Rule ::= Fun ":" Profiles "." Category "->" [Symbol];
terminator Rule ";";

Cons. Fun ::= Ident ;
Coerce. Fun ::= "_" ;

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

separator Profile ",";

UnifyProfile. Profile ::= "[" [Integer] "]";
ConstProfile. Profile ::= Ident ;

separator Integer ",";

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

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

Category. Category ::= SingleQuoteString ;

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