nex
nex copied to clipboard
The example with go yacc doesn't work
I was having trouble using nex with go yacc so I copied the example to test it out. I compiled, but it didn't work, as soon as I enter some text it breaks
Using: Mac OS 10.10.1 Go version go1.3.3 darwin/amd64
panic: syntax error
goroutine 16 [running]:
runtime.panic(0xa6300, 0x2081aa300)
/usr/local/Cellar/go/1.3.3/libexec/src/pkg/runtime/panic.c:279 +0xf5
main.Lexer.Error(0x2081ae0c0, 0x2081cc240, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe67f0, ...)
/Users/donnanicolas/go/src/tu-carrito.com/backend/extractor/rp/rp.nn.go:239 +0x67
main.(*Lexer).Error(0x2081c21e0, 0xe67f0, 0xc)
<autogenerated>:3 +0xa5
main.yyParse(0x22081bc340, 0x2081c21e0, 0x170bc8)
/Users/donnanicolas/go/src/tu-carrito.com/backend/extractor/rp/yaccpar:155 +0x563
main.main()
/Users/donnanicolas/go/src/tu-carrito.com/backend/extractor/rp/rp.nn.go:263 +0x84
goroutine 19 [finalizer wait]:
runtime.park(0x17f90, 0x170b90, 0x16ff09)
/usr/local/Cellar/go/1.3.3/libexec/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0x170b90, 0x16ff09)
/usr/local/Cellar/go/1.3.3/libexec/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
/usr/local/Cellar/go/1.3.3/libexec/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
/usr/local/Cellar/go/1.3.3/libexec/src/pkg/runtime/proc.c:1445
goroutine 20 [chan send]:
main.func·003(0x2081ae120, 0x2081ae0c0, 0x2081ea000, 0x3, 0x3, 0x0, 0x1)
/Users/donnanicolas/go/src/tu-carrito.com/backend/extractor/rp/rp.nn.go:136 +0x9c8
created by main.NewLexerWithInit
/Users/donnanicolas/go/src/tu-carrito.com/backend/extractor/rp/rp.nn.go:193 +0x677
I seem to be having a similar issue that when returning types from actions, EOF always panics. @blynn Can you add more examples of returning types from actions? For instance, this example
%%
"+" { return ADD; }
%%
I wrote nex way back in the Go 1.0 days, and looks like a lot has changed since then. I rarely use Go or yacc-like tools these days, so I'm afraid I don't know when I'll get around to fixing this.
@drewwells I've got a bunch of examples in https://github.com/purpleidea/mgmt/tree/master/lang
If that's not enough LMK. I have a plan to write a blog post about this all too.