1

我正在使用这种语法形式生成使用 Antlr 的解析器,但在执行此命令时

C:\Javalib>java -cp antlr-3.2.jar org.antlr.Tool Java.g

我收到以下错误,警告。此外,在从上述语法解析 ast 时遇到问题

warning(209): Java.g:1771:1: Multiple token rules can match input such as "'*'": STAR, STAREQ

As a result, token(s) STAREQ were disabled for that input
warning(209): Java.g:1811:1: Multiple token rules can match input such as "'i'": IF, IMPLEMENTS, IMPORT, INSTANCEOF, INT
, INTERFACE, IDENTIFIER

As a result, token(s) IMPLEMENTS,IMPORT,INSTANCEOF,INT,INTERFACE,IDENTIFIER were disabled for that input
warning(209): Java.g:1775:1: Multiple token rules can match input such as "'/'": COMMENT, LINE_COMMENT, SLASH, SLASHEQ

As a result, token(s) LINE_COMMENT,SLASH,SLASHEQ were disabled for that input
warning(209): Java.g:1811:1: Multiple token rules can match input such as "'n'": NATIVE, NEW, NULL, IDENTIFIER

As a result, token(s) NEW,NULL,IDENTIFIER were disabled for that input
warning(209): Java.g:1811:1: Multiple token rules can match input such as "'a'": ABSTRACT, ASSERT, IDENTIFIER

As a result, token(s) ASSERT,IDENTIFIER were disabled for that input
warning(209): Java.g:1791:1: Multiple token rules can match input such as "'%'": PERCENT, PERCENTEQ

As a result, token(s) PERCENTEQ were disabled for that input
warning(209): Java.g:1811:1: Multiple token rules can match input such as "'d'": DEFAULT, DO, DOUBLE, IDENTIFIER

As a result, token(s) DO,DOUBLE,IDENTIFIER were disabled for that input
warning(209): Java.g:1811:1: Multiple token rules can match input such as "'e'": ELSE, ENUM, EXTENDS, IDENTIFIER

As a result, token(s) ENUM,EXTENDS,IDENTIFIER were disabled for that input
warning(209): Java.g:1811:1: Multiple token rules can match input such as "'p'": PACKAGE, PRIVATE, PROTECTED, PUBLIC, ID
ENTIFIER

As a result, token(s) PRIVATE,PROTECTED,PUBLIC,IDENTIFIER were disabled for that input
warning(209): Java.g:1354:1: Multiple token rules can match input such as "'1'..'9'": LONGLITERAL, INTLITERAL, FLOATLITE
RAL, DOUBLELITERAL

As a result, token(s) INTLITERAL,FLOATLITERAL,DOUBLELITERAL were disabled for that input
warning(209): Java.g:1687:1: Multiple token rules can match input such as "'.'": FLOATLITERAL, DOUBLELITERAL, DOT, ELLIP
SIS

As a result, token(s) DOUBLELITERAL,DOT,ELLIPSIS were disabled for that input
warning(209): Java.g:1779:1: Multiple token rules can match input such as "'&'": AMPAMP, AMP, AMPEQ

As a result, token(s) AMP,AMPEQ were disabled for that input
warning(209): Java.g:1354:1: Multiple token rules can match input such as "'0'": LONGLITERAL, INTLITERAL, FLOATLITERAL,
DOUBLELITERAL

As a result, token(s) INTLITERAL,FLOATLITERAL,DOUBLELITERAL were disabled for that input
warning(209): Java.g:1811:1: Multiple token rules can match input such as "'b'": BOOLEAN, BREAK, BYTE, IDENTIFIER

As a result, token(s) BREAK,BYTE,IDENTIFIER were disabled for that input
warning(209): Java.g:1811:1: Multiple token rules can match input such as "'w'": WHILE, IDENTIFIER

As a result, token(s) IDENTIFIER were disabled for that input
warning(209): Java.g:1811:1: Multiple token rules can match input such as "'t'": THIS, THROW, THROWS, TRANSIENT, TRY, TR
UE, IDENTIFIER

As a result, token(s) THROW,THROWS,TRANSIENT,TRY,TRUE,IDENTIFIER were disabled for that input
warning(209): Java.g:1811:1: Multiple token rules can match input such as "'r'": RETURN, IDENTIFIER


As a result, token(s) STATIC,STRICTFP,SUPER,SWITCH,SYNCHRONIZED,IDENTIFIER were disabled for that input
warning(209): Java.g:1811:1: Multiple token rules can match input such as "'f'": FINAL, FINALLY, FLOAT, FOR, FALSE, IDEN
TIFIER

As a result, token(s) FINALLY,FLOAT,FOR,FALSE,IDENTIFIER were disabled for that input
warning(209): Java.g:1787:1: Multiple token rules can match input such as "'^'": CARET, CARETEQ

As a result, token(s) CARETEQ were disabled for that input
warning(209): Java.g:1811:1: Multiple token rules can match input such as "'g'": GOTO, IDENTIFIER

As a result, token(s) IDENTIFIER were disabled for that input
warning(209): Java.g:1783:1: Multiple token rules can match input such as "'|'": BARBAR, BAR, BAREQ

As a result, token(s) BAR,BAREQ were disabled for that input
warning(209): Java.g:1811:1: Multiple token rules can match input such as "'c'": CASE, CATCH, CHAR, CLASS, CONST, CONTIN
UE, IDENTIFIER

As a result, token(s) CATCH,CHAR,CLASS,CONST,CONTINUE,IDENTIFIER were disabled for that input
warning(209): Java.g:1711:1: Multiple token rules can match input such as "'='": EQ, EQEQ

As a result, token(s) EQEQ were disabled for that input
warning(209): Java.g:1763:1: Multiple token rules can match input such as "'+'": PLUSPLUS, PLUS, PLUSEQ

As a result, token(s) PLUS,PLUSEQ were disabled for that input
warning(209): Java.g:1767:1: Multiple token rules can match input such as "'-'": SUBSUB, SUB, SUBEQ

As a result, token(s) SUB,SUBEQ were disabled for that input
warning(209): Java.g:1811:1: Multiple token rules can match input such as "'v'": VOID, VOLATILE, IDENTIFIER

As a result, token(s) VOLATILE,IDENTIFIER were disabled for that input
error(208): Java.g:1799:1: The following token definitions can never be matched because prior tokens match the same inpu
t: INTLITERAL,DOUBLELITERAL,LINE_COMMENT,ASSERT,BREAK,BYTE,CATCH,CHAR,CLASS,CONST,CONTINUE,DO,DOUBLE,ENUM,EXTENDS,FINALL
Y,FLOAT,FOR,IMPLEMENTS,IMPORT,INSTANCEOF,INT,INTERFACE,NEW,PRIVATE,PROTECTED,PUBLIC,STATIC,STRICTFP,SUPER,SWITCH,SYNCHRO
NIZED,THROW,THROWS,TRANSIENT,TRY,VOLATILE,TRUE,FALSE,NULL,DOT,ELLIPSIS,EQEQ,PLUS,SUB,SLASH,AMP,BAR,PLUSEQ,SUBEQ,STAREQ,S
LASHEQ,AMPEQ,BAREQ,CARETEQ,PERCENTEQ,BANGEQ

有什么帮助吗?

4

1 回答 1

1

在这里使用这个语法。因为这对我有用。

于 2013-06-24T13:02:45.027 回答