mna / pigeon

Command pigeon generates parsers in Go from a PEG grammar.
BSD 3-Clause "New" or "Revised" License
822 stars 66 forks source link

Run from code? #107

Closed chkmls closed 1 year ago

chkmls commented 1 year ago

In pegjs the grammar could be used within the code with peg.generate(grammar) instead of command line. This could be achieve with pigeon too?

breml commented 1 year ago

@chkmls Thanks for your question. The way pigeon is built does not support to generate a parser on the fly by providing a grammar. I think it would be do-able somehow (e.g. with the use of a Go interpreter like https://github.com/traefik/yaegi), but it does not feel natural with a compiled language like Go and it is certainly not a goal for pigeon.

chkmls commented 1 year ago

Ok, thanks for the answer. Maybe there is a way to automat the generate? Now if there is an error on the grammar, there is a need to go to the shell and re run the command and compile again

breml commented 1 year ago

@chkmls I have used https://github.com/mitranim/gow for this in the past. You can combine it for example with https://taskfile.dev/.

chkmls commented 1 year ago

Great, thanks !