【问题标题】:jflex / cup - error: cannot find symbol { return symbol(sym.EQEQ);jflex / cup - 错误:找不到符号{返回符号(sym.EQEQ);
【发布时间】:2018-09-29 23:33:48
【问题描述】:

我正在尝试在以下位置运行示例: http://jflex.de/manual.html#Example 我复制了示例,只更改了文件/类名。

运行 jflex 似乎工作正常。

$ jflex -v -d output/ grammer/scanner.flex 
Reading "grammer/scanner.flex"
Constructing NFA : 148 states in NFA
Converting NFA to DFA : 
.........................................
45 states before minimization, 26 states in minimized DFA

下一步我尝试编译输出。无论我做什么,我都会收到这些错误。

$ javac -cp .*:dependancies/java-cup-11b.jar output/scanner.java 
output/scanner.java:788: error: cannot find symbol
            { return symbol(sym.IDENTIFIER);
                               ^
  symbol:   variable IDENTIFIER
  location: interface sym
output/scanner.java:793: error: cannot find symbol
            { return symbol(sym.INTEGER_LITERAL);
                               ^
  symbol:   variable INTEGER_LITERAL
  location: interface sym
output/scanner.java:803: error: cannot find symbol
            { return symbol(sym.EQ);
                               ^
  symbol:   variable EQ
  location: interface sym
output/scanner.java:808: error: cannot find symbol
            { return symbol(sym.PLUS);
                               ^
  symbol:   variable PLUS
  location: interface sym
output/scanner.java:819: error: cannot find symbol
                                   return symbol(sym.STRING_LITERAL,
                                                    ^
  symbol:   variable STRING_LITERAL
  location: interface sym
output/scanner.java:830: error: cannot find symbol
            { return symbol(sym.EQEQ);
                               ^
  symbol:   variable EQEQ
  location: interface sym
6 errors

我是不是忘记了什么?

http://czt.sourceforge.net/dev/java-cup-runtime/apidocs/java_cup/runtime/Symbol.html

【问题讨论】:

    标签: jflex cup


    【解决方案1】:

    使用 jflex,您正在生成 lexer

    您还需要使用 cup 生成 parser 并将其添加到您的类路径中。

    我建议你不要尝试手动编译,而是使用

    • 带有jflex-maven-plugincup-maven-plugin 的Maven。 见examples/simple/pom.xml
    • 或 bazel 以及 jflex()cup() 规则。 见examples/simple/BUILD

    PR 452 提议将此特定示例(目前在回归测试套件中)移动到示例目录中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-12
      • 2015-08-29
      • 1970-01-01
      • 1970-01-01
      • 2012-11-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多