Factor out grammar and runtime from parser.js