blynn / nex

Lexer for Go
http://cs.stanford.edu/~blynn/nex/
GNU General Public License v3.0
416 stars 47 forks source link

prototype: no channels #54

Open dragonsinth opened 4 years ago

dragonsinth commented 4 years ago

Partial implementation of discussion in #38

This works just fine for NN_FUN style lex; but it would need significantly more work to support writeLex correctly. I don't understand the internals enough to make much more progress on this myself tho.

1) writeLex generated code needs to propagate an int return value; nex_test8/tmp.go produces a compile error in this branch. I don't actually know what this return value is used for, since Lex is defined to always return 0.

2) In general, the way state is captured via closure in generated scan is probably not amenable to resuming the scan after escaping via panic-- the channel / goroutine approach sort of gives you this for "free". But again, I don't really understand the internals that well.