Make parser send error upwards instead of panicing

This commit is contained in:
Neemek 2024-12-29 14:49:31 +01:00
parent 402644d219
commit 6b90cc488e
Signed by: neemek
GPG key ID: 28360A8951CD0E9B
5 changed files with 246 additions and 129 deletions

View file

@ -39,14 +39,14 @@ func run(this js.Value, args []js.Value) interface{} {
parser := core.NewParser(tokens)
tree := parser.Parse()
tree, err := parser.Parse()
if err != nil {
return jsErrorOfString(err.Error())
}
log.Printf("Parsed tree: %s", tree.String())
if len(parser.Errors) > 0 {
return jsErrorOfString(parser.Errors[0].Description)
}
compiler := core.NewCompiler()
compiler.Compile(tree)