Reorganized parser helper functions to parser.js