Grammars
Regexes, rules, tokens can be combined into grammars:
grammar ABC { token integer { \d+ } token float { \d+ '.' \d* } token variable { <alpha>+ } token term { <float> | <integer> | <variable> } token addop { '+' | '-' } rule expr { <term> [ <addop> <term> ]* } rule if_stmt { 'if' <expr> <stmt> [ 'else' <stmt> ]? } rule print_stmt { 'print' <expr> } rule assign_stmt { <variable> '=' <expr> } rule stmt { <if_stmt> | <print_stmt> | <assign_stmt> } rule TOP { <stmt>* } }