parse function
Reads the lua file at path.
If there was an error, calls onErrors with those errors
and returns null.
Otherwise returns the constructed AST.
Implementation
AST? parse(String content, {RunnerErrorsCallback? onErrors}) {
final Lexer lexer = Lexer.tokenize(content)..dropComments();
if (lexer.errors.isNotEmpty) {
onErrors?.call(lexer.errors);
return null;
}
final Parser parser = Parser(lexer.tokens);
final ast = parser.analyze();
if (parser.errors.isNotEmpty) {
onErrors?.call(parser.errors);
return null;
}
return ast;
}