-
Notifications
You must be signed in to change notification settings - Fork 0
Metagrammar description
Unmyth edited this page Jan 4, 2012
·
2 revisions
Grammar file consists of the header with grammar name and rules:
Grammar : grammar str ';' Rules
Rules : Rule { [] }
| Rules Rule { : }
Rule : id '=' ClauseAlt ';' { Rule Nothing }
| id ':' id '=' ClauseAlt ';' { Rule Nothing }
| id '.' id ':' id '=' ClauseAlt ';' { Rule (Just ) }
| '.' id ':' id '=' ClauseAlt ';' { Rule "String" (Just ) }
ClauseAlt : ClauseAlt1 { Alt (reverse ) }
ClauseAlt1 : ClauseAlt1 '|' ClauseSeq { : }
| ClauseSeq { [] }
ClauseSeq : ClauseSeq1 { Seq (reverse ) }
ClauseSeq1 : ClauseSeq1 ClausePre { : }
| {- empty -} { [] }
ClausePre : '(' ClauseAlt ')' { }
| ',' ClausePost { Lifted }
| '!' ClausePost { Ignore }
| ClausePost { }
ClausePost : ClauseItem '*' OptDelim { Star }
| ClauseItem '+' OptDelim { Plus }
| ClauseItem '?' { Opt }
| ClauseItem { }
ClauseItem : id { Id }
| str { StrLit }
| '.' { Dot }
| rexplit { RegExpLit }
OptDelim : {- empty -} { Nothing }
| '~' ClauseItem { Just }