wschar:alias = " " | "\t" | "\n" | "\b" | "\f" | "\r" | "\v"; wsc:ws = wschar | comment; block-comment:alias:nows = "/*" ("*" [^/] | [^*])* "*/"; line-comment:alias:nows = "//" [^\n]*; comment-segment:alias:nows = line-comment | block-comment; ws-no-nl:alias:nows = " " | "\t" | "\b" | "\f" | "\r" | "\v"; comment:nows = comment-segment (ws-no-nl* "\n"? ws-no-nl* comment-segment)*; any-char = "."; // equivalent to [^] // caution: newline is accepted class-not = "^"; class-char:nows = [^\\\[\]\^\-] | "\\" .; char-range:nows = class-char "-" class-char; char-class:nows = "[" class-not? (class-char | char-range)* "]"; // newline is accepted sequence-char:nows = [^\\"] | "\\" .; char-sequence:nows = "\"" sequence-char* "\""; terminal:alias = any-char | char-class | char-sequence; symbol:nows = [^\\ \n\t\b\f\r\v/.\[\]\"{}\^+*?|():=;]+; group:alias = "(" expression ")"; number:alias:nows = [0-9]+; count = number; count-quantifier = "{" count "}"; range-from = number; range-to = number; range-quantifier = "{" range-from? "," range-to? "}"; one-or-more = "+"; zero-or-more = "*"; zero-or-one = "?"; quantity:alias = count-quantifier | range-quantifier | one-or-more | zero-or-more | zero-or-one; item:nows = (terminal | symbol | group) quantity?; sequence = item+; option:alias = terminal | symbol | group | sequence; // DOC: how the order matters choice = option ("|" option)+; // DOC: not having 'not' needs some tricks sometimes expression:alias = terminal | symbol | group | sequence | choice; alias = "alias"; ws = "ws"; nows = "nows"; root = "root"; flag:alias = alias | ws | nows | root; definition-name:alias:nows = symbol (":" flag)*; definition = definition-name "=" expression; definitions:alias = definition (";"+ definition)*; syntax:root = ";"* definitions? ";"*;