Reorganize code in parser.c