Refactored grammar: allow empty input