lexing parsing of rules, refactoring