refactor EBNF