Convert parser.c to C++