/***************************************************************************** Grammar for textual representation of grammars. *****************************************************************************/ /* regular expressions */ ID = [a-zA-Z0-9_\.]+ (MAX) WHITESPACE = [\ \t\n\r\f]+ (MAX) COMMENT = "/*"~(.*"*/".*)"*/"|"//"[^\r\n]* (MAX) NUMBER = [0-9]+ (MAX) NONRESERVEDCHAR = [^\ \.\"\#\@\|\&\~\?\*\+\{\}\(\)\<\>\[\]\-\/\\\b\t\n\r\f] ESCAPEDCHAR = \\(u[0-9a-fA-F]{4}|[^u\b\t\n\r\f]|[btnrf]) CHARCLASSCHAR = [^\^\]\\\-\b\t\n\r\f] STRING = ([^\"\\\b\t\n\r\f]|)* (MAX) /* main part of productions */ Grammar : _ RegexpDefs[regexps] Productions[productions] RegexpDefs[nonempty] : RegexpDef[regexp] __ RegexpDefs[more] [empty] | RegexpDef : [name] _ "=" _ Regexp[exp] OptMax[max] Productions[nonempty] : ProductionGroup[production] Productions[more] [empty] | ProductionGroup : [nonterminal] _ OptLabel[label] OptPriority[priority] ":" OptUnordered[unordered] Entities[entities] __ MoreProductions[more] MoreProductions[nonempty] : OptLabel[label] OptPriority[priority] "|" OptUnordered[unordered] Entities[entities] __ MoreProductions[more] [empty] | OptLabel[present] : "[" _ [label] _ "]" _ [absent] | OptPriority[higher] : ">" _ [same] | OptUnordered[present] : _ "&" [absent] | Entities[nonempty] : _ Entity[entity] Entities[more] [empty] | Entity[nonterminal] : [nonterminal] OptLabelOrExample[labelexample] [regexp_terminal] | "<" [regexp] ">" OptLabelOrExample[labelexample] [string_terminal] | "\"" [string] "\"" OptLabelOrExample[label] : "[" _ [label] _ "]" [example] | "[" _ "\"" [example] "\"" _ "]" [absent] | /* syntax for regular expressions */ Regexp : UnionExp[e] UnionExp[union] : InterExp[e] "|" UnionExp[more] [other] | InterExp[e] InterExp[inter] : ConcatExp[e] "&" InterExp[more] [other] | ConcatExp[e] ConcatExp[concat] : RepeatExp[e] ConcatExp[more] [other] | RepeatExp[e] RepeatExp[optional] : RepeatExp[e] "?" [star] | RepeatExp[e] "*" [plus] | RepeatExp[e] "+" [number] | RepeatExp[e] "{" [n] "}" [min] | RepeatExp[e] "{" [n] ",}" [interval] | RepeatExp[e] "{" [n] "," [m] "}" [other] | ComplExp[e] ComplExp[complement] : "~" ComplExp[e] [other] | CharclassExp[e] CharclassExp[charclass] : "[" Charclasses[c] "]" [negativeclass] | "[^" Charclasses[c] "]" [other] | SimpleExp[e] Charclasses[first] : Charclass[c] Charclasses[more] [last] | Charclass[c] Charclass[interval] : Charclasschar[c1] "-" Charclasschar[c2] [single] | Charclasschar[c] Charclasschar[char] : [c] [escape] | [c] SimpleExp[char] : [c] [escape] | [c] [dot] | "." [empty] | "#" [all] | "@" [string] | "\"" [string] "\"" [epsilon] | "()" [exp] | "(" UnionExp[e] ")" [named] | "<" [id] ">" [numeric] | "<" [n] "-" [m] ">" OptMax[present] : __ "(" "MAX" ")" [absent] | /* whitespace and other ignorable stuff */ Ignorable : | | __ : Ignorable _ _ : Ignorable _ |