简体   繁体   English

使JFlex和Cup一起工作

[英]Getting JFlex and Cup to work together

I'm trying to implement a parser with JFlex and Cup. 我正在尝试使用JFlex和Cup实现解析器。 Right now I'm just trying to get them to compile the simple example program found at the link below. 现在,我只是想让他们编译以下链接中找到的简单示例程序。

http://www.cs.rit.edu/~pal6640/cup-example/simple-expr.html http://www.cs.rit.edu/~pal6640/cup-example/simple-expr.html

To create the parser.java and sym.java file from the cup script I run: 要从cup脚本创建parser.javasym.java文件,请运行:

java –jar java-cup-11a.jar parser.cup

Next, I use JFlex.jar to create the lexer java file: 接下来,我使用JFlex.jar创建lexer java文件:

java –jar JFlex.jar lexer.lex

Then to compile: 然后编译:

javac –classpath java-cup-11a.jar Yylex.java sym.java parser.java

The compile command throws 12 errors . 编译命令将引发12个错误 They all say 他们都说

cannot find the symbol variable scanner 找不到符号变量扫描器

I think that I have all my environment variables set correctly. 我认为我已正确设置了所有环境变量。 Does anyone know what I'm doing wrong? 有人知道我在做什么错吗?

Java CUP distributes two jar files: executable standalone Jar-package and CUP runtime-library to use in conjunction with CUP generated parsers . Java CUP分发了两个jar文件: 可执行的独立Jar-packageCUP运行时库,可与CUP生成的解析器结合使用 The parser generated by CUP needs the second one. CUP生成的解析器需要第二个解析器。 Therefore your third command should be something like 因此,您的第三个命令应类似于

javac –classpath java-cup-11a-runtime.jar Yylex.java sym.java parser.java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM