The parser depends on the MOO lexical analyzer to handle the dirty work of dividing the input into recognizable tokens.
The parser's interface looks like this:
string program, *errors; mixed *result, *ast; result = PARSER->main(program); if (result[0]) { ast = result[1]; ... } else { errors = result[1]; ... }If the program was parsed successfully,
({ 1,
AST })
is returned containing the abstract syntax tree for the program. Otherwise,
({ 0,
errors })
is returned, where errors is an array of strings describing each of
the errors found in the program.