(*
 * A Grako grammar for simple regular expression;

   Because whitespace is significant in regular expressions,
   all rule names start with an uppercase letter so whitespace
   is not skipped when invoking them;
 *)

START = EXPRE $ ;

EXPRE = CHOICE | SEQUENCE ;

CHOICE = opts+:SEQUENCE {'|' ~ opts+:SEQUENCE}+ ;

SEQUENCE = terms:{TERM}+ ;

TERM = CLOSURE | ATOM ;

CLOSURE = @:ATOM '*' ~  ;

ATOM = SUBEXP | LITERAL ;

SUBEXP = '(' ~ @:EXPRE ')' ;

LITERAL = ?/(?:\\;|[^|*\\()])+/? ;
