|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Oct 2012
Messaggi: 59
|
ANTLR - Problema durante compilazione
Ciao a tutti, devo usare antlr per l'università ma non so se l'ho installato bene.
Premetto che sto usando Windows 7 64 bit. Ho scaricato da http://www.antlr3.org/download/antlr-3.5-complete.jar la versione 3.5 di antlr e da http://www.antlr3.org/download/antlrworks-1.4.2.jar antlrwork 1.4.2. Poi ho messo questi due file in una cartella C:\Javalib ed ho impostato il classpath aggiungendo C:\Javalib\antlr-3.5-complete.jar; alla variabile d'ambiente Path (è la stessa a cui ho aggiunto anche il percorso delle jkd di java). Poi, per esempio, ho provato a seguire i passi descritti qui http://www.antlr.org/wiki/display/AN...ion+evaluator. Quindi ho copiato il testo della grammatica in un file Expr.g e l'ho salvato sempre nella cartella C:\Javalib. Poi dal prompt dei comandi ho eseguito (trovandomi in C:\Javalib) java -cp antlr-3.5-complete.jar org.antlr.Tool Expr.g ed effettivamente mi ha prodotto i 3 file ExprLexer.java, ExprParser.java e Expr.tokens. Fin qui quindi tutto bene... Ora iniziano i problemi. Ho poi copiato in un file java il programmino Test.java e ho provato a compilarlo eseguendo dal prompt dei comandi (dopo essermi posizionato nella cartella C:\Javalib) javac Test.java ExprLexer.java ExprParser.java ma mi da errore, anzi.. mi da 100 errori. Ho provato allora scrivendo sul prompt javac -cp .:.\antlr-3.5-complete.jar Test.java ExprLexer.java ExprParser.java e javac -cp .;C:\antlr-3.5-complete.jar Test.java ExprLexer.java ExprParser.java ma niente, sempre gli stessi 100 errori. Ho installato bene tutto? Le variabili d'ambiente sono corrette? Come faccio a compilare? Grazie |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: May 2008
Città: Seattle (WA)
Messaggi: 306
|
Quali Errori ti da ?
__________________
"Considerate la vostra semenza fatti non foste a viver come bruti ma per seguir virtute e canoscenza" |
|
|
|
|
|
#3 |
|
Member
Iscritto dal: Oct 2012
Messaggi: 59
|
Grazie per la risposta. Ecco gli errori:
location: class ExprParser ExprParser.java:434: error: cannot find symbol public static final BitSet FOLLOW_INT_in_atom230 = new BitSet(new long[] {0x0000000000000002L}); ^ symbol: class BitSet location: class ExprParser ExprParser.java:435: error: cannot find symbol public static final BitSet FOLLOW_ID_in_atom242 = new BitSet(new long[]{ 0x0000000000000002L}); ^ symbol: class BitSet location: class ExprParser ExprParser.java:436: error: cannot find symbol public static final BitSet FOLLOW_8_in_atom262 = new BitSet(new long[]{0 x0000000000000130L}); ^ symbol: class BitSet location: class ExprParser ExprParser.java:437: error: cannot find symbol public static final BitSet FOLLOW_expr_in_atom264 = new BitSet(new long[ ]{0x0000000000000200L}); ^ symbol: class BitSet location: class ExprParser ExprParser.java:438: error: cannot find symbol public static final BitSet FOLLOW_9_in_atom266 = new BitSet(new long[]{0 x0000000000000002L}); ^ symbol: class BitSet location: class ExprParser Test.java:5: error: cannot find symbol ANTLRInputStream input = new ANTLRInputStream(System.in); ^ symbol: class ANTLRInputStream location: class Test Test.java:5: error: cannot find symbol ANTLRInputStream input = new ANTLRInputStream(System.in); ^ symbol: class ANTLRInputStream location: class Test Test.java:7: error: cannot find symbol CommonTokenStream tokens = new CommonTokenStream(lexer); ^ symbol: class CommonTokenStream location: class Test Test.java:7: error: cannot find symbol CommonTokenStream tokens = new CommonTokenStream(lexer); ^ symbol: class CommonTokenStream location: class Test ExprLexer.java:25: error: cannot find symbol return new Lexer[] {}; ^ symbol: class Lexer location: class ExprLexer ExprLexer.java:30: error: cannot find symbol this(input, new RecognizerSharedState()); ^ symbol: class RecognizerSharedState location: class ExprLexer ExprLexer.java:35: error: method does not override or implement a method from a supertype @Override public String getGrammarFileName() { return "Expr.g"; } ^ ExprLexer.java:41: error: cannot find symbol int _channel = DEFAULT_TOKEN_CHANNEL; ^ symbol: variable DEFAULT_TOKEN_CHANNEL location: class ExprLexer ExprLexer.java:45: error: cannot find symbol match('('); ^ symbol: method match(char) location: class ExprLexer ExprLexer.java:48: error: cannot find symbol state.type = _type; ^ symbol: variable state location: class ExprLexer ExprLexer.java:49: error: cannot find symbol state.channel = _channel; ^ symbol: variable state location: class ExprLexer ExprLexer.java:61: error: cannot find symbol int _channel = DEFAULT_TOKEN_CHANNEL; ^ symbol: variable DEFAULT_TOKEN_CHANNEL location: class ExprLexer ExprLexer.java:65: error: cannot find symbol match(')'); ^ symbol: method match(char) location: class ExprLexer ExprLexer.java:68: error: cannot find symbol state.type = _type; ^ symbol: variable state location: class ExprLexer ExprLexer.java:69: error: cannot find symbol state.channel = _channel; ^ symbol: variable state location: class ExprLexer ExprLexer.java:81: error: cannot find symbol int _channel = DEFAULT_TOKEN_CHANNEL; ^ symbol: variable DEFAULT_TOKEN_CHANNEL location: class ExprLexer ExprLexer.java:85: error: cannot find symbol match('*'); ^ symbol: method match(char) location: class ExprLexer ExprLexer.java:88: error: cannot find symbol state.type = _type; ^ symbol: variable state location: class ExprLexer ExprLexer.java:89: error: cannot find symbol state.channel = _channel; ^ symbol: variable state location: class ExprLexer ExprLexer.java:101: error: cannot find symbol int _channel = DEFAULT_TOKEN_CHANNEL; ^ symbol: variable DEFAULT_TOKEN_CHANNEL location: class ExprLexer ExprLexer.java:105: error: cannot find symbol match('+'); ^ symbol: method match(char) location: class ExprLexer ExprLexer.java:108: error: cannot find symbol state.type = _type; ^ symbol: variable state location: class ExprLexer ExprLexer.java:109: error: cannot find symbol state.channel = _channel; ^ symbol: variable state location: class ExprLexer ExprLexer.java:121: error: cannot find symbol int _channel = DEFAULT_TOKEN_CHANNEL; ^ symbol: variable DEFAULT_TOKEN_CHANNEL location: class ExprLexer ExprLexer.java:125: error: cannot find symbol match('-'); ^ symbol: method match(char) location: class ExprLexer ExprLexer.java:128: error: cannot find symbol state.type = _type; ^ symbol: variable state location: class ExprLexer ExprLexer.java:129: error: cannot find symbol state.channel = _channel; ^ symbol: variable state location: class ExprLexer ExprLexer.java:141: error: cannot find symbol int _channel = DEFAULT_TOKEN_CHANNEL; ^ symbol: variable DEFAULT_TOKEN_CHANNEL location: class ExprLexer ExprLexer.java:145: error: cannot find symbol match('='); ^ symbol: method match(char) location: class ExprLexer ExprLexer.java:148: error: cannot find symbol state.type = _type; ^ symbol: variable state location: class ExprLexer ExprLexer.java:149: error: cannot find symbol state.channel = _channel; ^ symbol: variable state location: class ExprLexer ExprLexer.java:161: error: cannot find symbol int _channel = DEFAULT_TOKEN_CHANNEL; ^ symbol: variable DEFAULT_TOKEN_CHANNEL location: class ExprLexer ExprLexer.java:170: error: cannot find symbol int LA1_0 = input.LA(1); ^ symbol: variable input location: class ExprLexer ExprLexer.java:179: error: cannot find symbol if ( (input.LA(1) >= 'A' && input.LA(1) <= 'Z')||(input.LA(1) >= 'a' && input.LA(1) <= 'z') ) { ^ symbol: variable input location: class ExprLexer ExprLexer.java:179: error: cannot find symbol if ( (input.LA(1) >= 'A' && input.LA(1) <= 'Z')||(input.LA(1) >= 'a' && input.LA(1) <= 'z') ) { ^ symbol: variable input location: class ExprLexer ExprLexer.java:179: error: cannot find symbol if ( (input.LA(1) >= 'A' && input.LA(1) <= 'Z')||(input.LA(1) >= 'a' && input.LA(1) <= 'z') ) { ^ symbol: variable input location: class ExprLexer ExprLexer.java:179: error: cannot find symbol if ( (input.LA(1) >= 'A' && input.LA(1) <= 'Z')||(input.LA(1) >= 'a' && input.LA(1) <= 'z') ) { ^ symbol: variable input location: class ExprLexer ExprLexer.java:180: error: cannot find symbol input.consume(); ^ symbol: variable input location: class ExprLexer ExprLexer.java:183: error: cannot find symbol MismatchedSetException mse = new MismatchedSetException(null,input); ^ symbol: class MismatchedSetException location: class ExprLexer ExprLexer.java:183: error: cannot find symbol MismatchedSetException mse = new MismatchedSetException(null,input); ^ symbol: class MismatchedSetException location: class ExprLexer ExprLexer.java:183: error: cannot find symbol MismatchedSetException mse = new MismatchedSetException(null,input); ^ symbol: variable input location: class ExprLexer ExprLexer.java:192: error: cannot find symbol EarlyExitException eee = new EarlyExitEx ception(1, input); ^ symbol: class EarlyExitException location: class ExprLexer ExprLexer.java:192: error: cannot find symbol EarlyExitException eee = new EarlyExitEx ception(1, input); ^ symbol: class EarlyExitException location: class ExprLexer ExprLexer.java:192: error: cannot find symbol EarlyExitException eee = new EarlyExitEx ception(1, input); ^ symbol: variable input location: class ExprLexer ExprLexer.java:200: error: cannot find symbol state.type = _type; ^ symbol: variable state location: class ExprLexer ExprLexer.java:201: error: cannot find symbol state.channel = _channel; ^ symbol: variable state location: class ExprLexer ExprLexer.java:213: error: cannot find symbol int _channel = DEFAULT_TOKEN_CHANNEL; ^ symbol: variable DEFAULT_TOKEN_CHANNEL location: class ExprLexer ExprLexer.java:222: error: cannot find symbol int LA2_0 = input.LA(1); ^ symbol: variable input location: class ExprLexer ExprLexer.java:231: error: cannot find symbol if ( (input.LA(1) >= '0' && input.LA(1) <= '9') ) { ^ symbol: variable input location: class ExprLexer ExprLexer.java:231: error: cannot find symbol if ( (input.LA(1) >= '0' && input.LA(1) <= '9') ) { ^ symbol: variable input location: class ExprLexer 100 errors C:\Javalib> |
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: May 2008
Città: Seattle (WA)
Messaggi: 306
|
È evidente che ti manca qualcosa
Codice:
javac -cp ecc.. Codice:
javac -cp .:antlr-3.5-complete.jar Test.java ExprLexer.java ExprParser.java Codice:
java -cp .:antlr-3.5-complete.jar Test
__________________
"Considerate la vostra semenza fatti non foste a viver come bruti ma per seguir virtute e canoscenza" |
|
|
|
|
|
#5 | |
|
Member
Iscritto dal: Oct 2012
Messaggi: 59
|
Quote:
Mi sento un pò rinco.. |
|
|
|
|
|
|
#6 |
|
Senior Member
Iscritto dal: May 2008
Città: Seattle (WA)
Messaggi: 306
|
L'unica differenza è che io ho linux e te windows quindi magari cambia qualcosa nella sintassi del parametro -cp.... Investiga, su quello..
__________________
"Considerate la vostra semenza fatti non foste a viver come bruti ma per seguir virtute e canoscenza" |
|
|
|
|
|
#7 |
|
Senior Member
Iscritto dal: May 2008
Città: Seattle (WA)
Messaggi: 306
|
L'unica differenza è che io ho linux e te windows quindi magari cambia qualcosa nella sintassi del parametro -cp.... Investiga, su quello..
__________________
"Considerate la vostra semenza fatti non foste a viver come bruti ma per seguir virtute e canoscenza" |
|
|
|
|
|
#8 |
|
Member
Iscritto dal: Oct 2012
Messaggi: 59
|
|
|
|
|
|
|
#9 |
|
Member
Iscritto dal: Oct 2012
Messaggi: 59
|
Non sono ancora riuscito a risolvere...
|
|
|
|
|
|
#10 |
|
Senior Member
Iscritto dal: May 2008
Città: Seattle (WA)
Messaggi: 306
|
Non so proprio come aiutarti, windows non lo uso da tempi assai remoti (meno male
__________________
"Considerate la vostra semenza fatti non foste a viver come bruti ma per seguir virtute e canoscenza" |
|
|
|
|
|
#11 | |
|
Member
Iscritto dal: Oct 2012
Messaggi: 59
|
Quote:
|
|
|
|
|
|
|
#12 |
|
Senior Member
Iscritto dal: May 2008
Città: Seattle (WA)
Messaggi: 306
|
SI trattava di mettere il ; alla fine dell'argomento -cp:
Codice:
java -cp antlr-3.5-complete.jar; Test
__________________
"Considerate la vostra semenza fatti non foste a viver come bruti ma per seguir virtute e canoscenza" |
|
|
|
|
|
#13 |
|
Member
Iscritto dal: Oct 2012
Messaggi: 59
|
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 09:38.



















