gopikchr / golemon

A Go port of the lemon parser generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go lemon port

A port of the Lemon Parser to Go.

State

This work was done entirely in support of gopikchr. It works well enough to turn pikchr.y into pikchr.go, but there are almost certainly further bugs. Pull requests are welcome: I intend no support for this project, but if you're obscure enough to want a Go port of the Lemon Parser, then we share a strange kind of kinship, and I welcome your contributions.

Goals

  • Keep the code structure as close to the original as possible, to make tracking and applying future changes as straight-forward as possible.
  • Convert to Go idioms only where the conversion remains clear.

See also

  • nsf/golemon - 11 years out-of date 😞. Went in the opposite direction: the parser generator is still written in C, but generates Go code

Changes

  • You must define func testcase(bool) in your code.
  • The various #defines have been turned into constants.

TODOs

  • Use the embed package to embed the template in the binary.
  • Create a github action that follows the rss feed for changes to lemon.c and lempar.c and creates issues. - [ ] Figure out a better way to do constants: either put them in a separate file that is only (re)generated optionally, or make them settable with flags, or something.
  • Possibly, go back and incorporate the lessons learned from porting pikchr.y to Go: use a []byte to represent the main char * pointers and pointer arithmetic, instead of converting to []rune.

Contributors

About

A Go port of the lemon parser generator

License:MIT License


Languages

Language:Go 54.1%Language:C 39.5%Language:Smarty 6.0%Language:Yacc 0.3%