A proof-of-concept, coupling goyacc with flexgo.

go get


What is this?

This is a proof-of-concept app that combines the goyacc parser:

with the flexgo lexer:

The idea is to use the two in tandem as bison and flex are used in C.

The generate directives below will produce .go files from the parser and lexer files. The prefixing is necessary to avoid name collisions between the two tools when their .go outputs are destined for the same package.


goyacc is expected to be in the $PATH while flexgo is expected to be precisely in $GOPATH/bin in order for the generate directive to work.


You can simply run make to build the example program. Or if you feel like doing it manually, read on...

To generate the lexer and parser files:

go generate

To build the example program:

go build


To run the program:


The application waits for the user to enter an expression.

For this example, the END-OF-INPUT must be given after the expression is entered (i.e. the user presses Enter and gives a new line.) For UNIX/Linux systems, this means that Ctrl + D must be given to see the result I hope to fix this soon to make the example easier and much more clear.