refactor EBNF to sewing form