우분투에서 JFlex 및 컵 도구에 대해 배우고 싶습니다. 학교 프로젝트에 사용해야하기 때문에. 그래서 저는 JFlex와 Cup을 다운로드하여 설치했습니다. "jflex-1.6.1/examples"에는 몇 가지 예제가 있으므로, 그 중 하나를 실행하려고했습니다.Jlex 및 컵 도구 사용 방법
컴파일하려면 :
jflex lcalc.flex
java java_cup.Main < ycalc.cup
javac Main.java
을 실행하려면 :
java Main test.txt
특히 나는 README 파일의 지침에 따라, "jflex-1.6.1/예/컵"의 하나를 실행하려고
파일 : 많은 어려움
"Main.java" demo of a main program
"Makefile " makefile to compile and test the example
"README"
"lcalc.flex" the lexer spec
"output.good " how the output should look like for the test
"ycalc.cup" the parser spec
"test.txt " sample input for testing
, 내가 성공을 완료 한 후, 컴파일 마침내 수 있었다 처음 세 명령을 완전히 읽으십시오. 이제 실행할 때 오류가 있습니다 : java Main test.txt. 특히 나는이 오류가 발생합니다 :
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: java_cup/runtime/Scanner
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: java_cup.runtime.Scanner
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
이 문제를 해결하는 방법에 대해 잘 모릅니다. 나는 다른 예에서도 시도했지만 결과는 같았다. 도와 주시면 감사하겠습니다. 고맙습니다!