Skip to content

Metagrammar description

Unmyth edited this page Jan 6, 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 ';'
     | id ':' id '=' ClauseAlt ';'
     | id '.' id ':' id '=' ClauseAlt ';'
     | '.' id ':' id '=' ClauseAlt ';'

ClauseAlt : ClauseAlt1

ClauseAlt1 : ClauseAlt1 '|' ClauseSeq
           | ClauseSeq 

ClauseSeq : ClauseSeq1 

ClauseSeq1 : ClauseSeq1 ClausePre 
           | {- empty -}   

ClausePre : '(' ClauseAlt ')'   
          | ',' ClausePost 
          | '!' ClausePost 
          | ClausePost  

ClausePost : ClauseItem '*' OptDelim 
           | ClauseItem '+' OptDelim
           | ClauseItem '?' 
           | ClauseItem   


ClauseItem : id  
           | str 
           | '.' 
           | rexplit   

OptDelim : {- empty -}   
         | '~' ClauseItem 

Clone this wiki locally