Refactor ShellGrammar