How to use Jflex and Bison Together?

277 Views Asked by At

I am really struggling to use Jflex and Bison together. For example, here's some sample code:

https://github.com/valecor95/bison-flex-jflex-examples/tree/master/Java/1_BalancedParentheses/BalPar1

You run make: enter image description here

It just makes a load of files, and then if I want to test to see if it succeeds with the parser (stuff in a file called test.txt), I just can't. It's forced to take in System.in. It's really frustrating as there's very little readable and simple documentation for JFLEX and bison.

Any advice at all would be much appreciated.

1

There are 1 best solutions below

0
rici On

In BalPar.y line 15, right at the beginning of main, it instantiates a BalParLexer with System.in as its input stream. You could add a few lines of code to check for a command line argument and use it as the name of a file to open instead of System.in.

That's all pretty well independent of Bison and JFkex.