[英]How to use Jflex and Bison Together?
I am really struggling to use Jflex and Bison together.我真的很难同时使用 Jflex 和 Bison。 For example, here's some sample code:
例如,这里有一些示例代码:
https://github.com/valecor95/bison-flex-jflex-examples/tree/master/Java/1_BalancedParentheses/BalPar1 https://github.com/valecor95/bison-flex-jflex-examples/tree/master/Java/1_BalancedParentheses/BalPar1
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.它只会产生大量文件,然后如果我想测试它是否成功使用解析器(在名为 test.txt 的文件中的东西),我就是做不到。 It's forced to take in System.in.
它被迫接受System.in。 It's really frustrating as there's very little readable and simple documentation for JFLEX and bison.
这真的很令人沮丧,因为 JFLEX 和 bison 的可读性和简单文档很少。
Any advice at all would be much appreciated.任何建议都将不胜感激。
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.在 BalPar.y 的第 15 行中,就在 main 的开头,它实例化了一个 BalParLexer 并将
System.in
作为其输入 stream。您可以添加几行代码来检查命令行参数并将其用作要打开的文件而不是 System.in。
That's all pretty well independent of Bison and JFkex.这完全独立于 Bison 和 JFkex。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.