gnucparser.java
来自「plugin for eclipse」· Java 代码 · 共 2,584 行 · 第 1/5 页
JAVA
2,584 行
else {
throw new NoViableAltException(LT(1), getFilename());
}
}}
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_2);
} else {
throw ex;
}
}
returnAST = externalDef_AST;
}
public final void declaration() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode declaration_AST = null;
TNode ds_AST = null;
AST ds1 = null;
try { // for error handling
declSpecifiers();
ds_AST = (TNode)returnAST;
astFactory.addASTChild(currentAST, returnAST);
if ( inputState.guessing==0 ) {
ds1 = astFactory.dupList(ds_AST);
}
{
switch ( LA(1)) {
case ID:
case STAR:
case LPAREN:
{
initDeclList(ds1);
astFactory.addASTChild(currentAST, returnAST);
break;
}
case SEMI:
{
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
{
int _cnt2135=0;
_loop2135:
do {
if ((LA(1)==SEMI) && (_tokenSet_12.member(LA(2)))) {
TNode tmp10_AST = null;
tmp10_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp10_AST);
match(SEMI);
}
else {
if ( _cnt2135>=1 ) { break _loop2135; } else {throw new NoViableAltException(LT(1), getFilename());}
}
_cnt2135++;
} while (true);
}
if ( inputState.guessing==0 ) {
declaration_AST = (TNode)currentAST.root;
declaration_AST = (TNode)astFactory.make( (new ASTArray(2)).add((TNode)astFactory.create(NDeclaration)).add(declaration_AST));
currentAST.root = declaration_AST;
currentAST.child = declaration_AST!=null &&declaration_AST.getFirstChild()!=null ?
declaration_AST.getFirstChild() : declaration_AST;
currentAST.advanceChildToEnd();
}
declaration_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_12);
} else {
throw ex;
}
}
returnAST = declaration_AST;
}
public final void functionPrefix() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode functionPrefix_AST = null;
TNode ds_AST = null;
TNode d_AST = null;
String declName;
try { // for error handling
{
boolean synPredMatched2075 = false;
if (((_tokenSet_13.member(LA(1))) && (_tokenSet_14.member(LA(2))))) {
int _m2075 = mark();
synPredMatched2075 = true;
inputState.guessing++;
try {
{
functionDeclSpecifiers();
}
}
catch (RecognitionException pe) {
synPredMatched2075 = false;
}
rewind(_m2075);
inputState.guessing--;
}
if ( synPredMatched2075 ) {
functionDeclSpecifiers();
ds_AST = (TNode)returnAST;
astFactory.addASTChild(currentAST, returnAST);
}
else if ((_tokenSet_10.member(LA(1))) && (_tokenSet_9.member(LA(2)))) {
}
else {
throw new NoViableAltException(LT(1), getFilename());
}
}
declName=declarator(true);
d_AST = (TNode)returnAST;
astFactory.addASTChild(currentAST, returnAST);
{
_loop2077:
do {
if ((_tokenSet_6.member(LA(1)))) {
declaration();
astFactory.addASTChild(currentAST, returnAST);
}
else {
break _loop2077;
}
} while (true);
}
{
switch ( LA(1)) {
case VARARGS:
{
TNode tmp11_AST = null;
tmp11_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp11_AST);
match(VARARGS);
break;
}
case LCURLY:
case SEMI:
{
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
{
_loop2080:
do {
if ((LA(1)==SEMI)) {
TNode tmp12_AST = null;
tmp12_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp12_AST);
match(SEMI);
}
else {
break _loop2080;
}
} while (true);
}
TNode tmp13_AST = null;
tmp13_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp13_AST);
match(LCURLY);
functionPrefix_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_0);
} else {
throw ex;
}
}
returnAST = functionPrefix_AST;
}
public final void functionDef() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode functionDef_AST = null;
TNode ds_AST = null;
TNode d_AST = null;
String declName;
try { // for error handling
{
boolean synPredMatched2298 = false;
if (((_tokenSet_13.member(LA(1))) && (_tokenSet_14.member(LA(2))))) {
int _m2298 = mark();
synPredMatched2298 = true;
inputState.guessing++;
try {
{
functionDeclSpecifiers();
}
}
catch (RecognitionException pe) {
synPredMatched2298 = false;
}
rewind(_m2298);
inputState.guessing--;
}
if ( synPredMatched2298 ) {
functionDeclSpecifiers();
ds_AST = (TNode)returnAST;
astFactory.addASTChild(currentAST, returnAST);
}
else if ((_tokenSet_10.member(LA(1))) && (_tokenSet_9.member(LA(2)))) {
}
else {
throw new NoViableAltException(LT(1), getFilename());
}
}
declName=declarator(true);
d_AST = (TNode)returnAST;
astFactory.addASTChild(currentAST, returnAST);
if ( inputState.guessing==0 ) {
AST d2, ds2;
d2 = astFactory.dupList(d_AST);
ds2 = astFactory.dupList(ds_AST);
symbolTable.add(declName, (TNode)astFactory.make( (new ASTArray(3)).add(null).add(ds2).add(d2)));
pushScope(declName);
}
{
_loop2300:
do {
if ((_tokenSet_6.member(LA(1)))) {
declaration();
astFactory.addASTChild(currentAST, returnAST);
}
else {
break _loop2300;
}
} while (true);
}
{
switch ( LA(1)) {
case VARARGS:
{
TNode tmp14_AST = null;
tmp14_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp14_AST);
match(VARARGS);
break;
}
case LCURLY:
case SEMI:
{
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
{
_loop2303:
do {
if ((LA(1)==SEMI)) {
match(SEMI);
}
else {
break _loop2303;
}
} while (true);
}
if ( inputState.guessing==0 ) {
popScope();
}
compoundStatement(declName);
astFactory.addASTChild(currentAST, returnAST);
if ( inputState.guessing==0 ) {
functionDef_AST = (TNode)currentAST.root;
functionDef_AST = (TNode)astFactory.make( (new ASTArray(2)).add((TNode)astFactory.create(NFunctionDef)).add(functionDef_AST));
currentAST.root = functionDef_AST;
currentAST.child = functionDef_AST!=null &&functionDef_AST.getFirstChild()!=null ?
functionDef_AST.getFirstChild() : functionDef_AST;
currentAST.advanceChildToEnd();
}
functionDef_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_2);
} else {
throw ex;
}
}
returnAST = functionDef_AST;
}
public final void typelessDeclaration() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode typelessDeclaration_AST = null;
AST typeMissing = (TNode)astFactory.create(NTypeMissing);
try { // for error handling
initDeclList(typeMissing);
astFactory.addASTChild(currentAST, returnAST);
TNode tmp16_AST = null;
tmp16_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp16_AST);
match(SEMI);
if ( inputState.guessing==0 ) {
typelessDeclaration_AST = (TNode)currentAST.root;
typelessDeclaration_AST = (TNode)astFactory.make( (new ASTArray(2)).add((TNode)astFactory.create(NTypeMissing)).add(typelessDeclaration_AST));
currentAST.root = typelessDeclaration_AST;
currentAST.child = typelessDeclaration_AST!=null &&typelessDeclaration_AST.getFirstChild()!=null ?
typelessDeclaration_AST.getFirstChild() : typelessDeclaration_AST;
currentAST.advanceChildToEnd();
}
typelessDeclaration_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_2);
} else {
throw ex;
}
}
returnAST = typelessDeclaration_AST;
}
public final void functionDeclSpecifiers() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode functionDeclSpecifiers_AST = null;
int specCount = 0;
try { // for error handling
{
int _cnt2308=0;
_loop2308:
do {
switch ( LA(1)) {
case LITERAL_extern:
case LITERAL_static:
case LITERAL_inline:
{
functionStorageClassSpecifier();
astFactory.addASTChild(currentAST, returnAST);
break;
}
case LITERAL_volatile:
case LITERAL_const:
{
typeQualifier();
astFactory.addASTChild(currentAST, returnAST);
break;
}
default:
boolean synPredMatched2307 = false;
if (((_tokenSet_15.member(LA(1))) && (_tokenSet_14.member(LA(2))))) {
int _m2307 = mark();
synPredMatched2307 = true;
inputState.guessing++;
try {
{
if ((LA(1)==LITERAL_struct) && (true)) {
match(LITERAL_struct);
}
else if ((LA(1)==LITERAL_union) && (true)) {
match(LITERAL_union);
}
else if ((LA(1)==LITERAL_enum) && (true)) {
match(LITERAL_enum);
}
else if ((_tokenSet_15.member(LA(1))) && (true)) {
typeSpecifier(specCount);
}
else {
throw new NoViableAltException(LT(1), getFilename());
}
}
}
catch (RecognitionException pe) {
synPredMatched2307 = false;
}
rewind(_m2307);
inputState.guessing--;
}
if ( synPredMatched2307 ) {
specCount=typeSpecifier(specCount);
astFactory.addASTChild(currentAST, returnAST);
}
else {
if ( _cnt2308>=1 ) { break _loop2308; } else {throw new NoViableAltException(LT(1), getFilename());}
}
}
_cnt2308++;
} while (true);
}
functionDeclSpecifiers_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_10);
} else {
throw ex;
}
}
returnAST = functionDeclSpecifiers_AST;
}
public final String declarator(
boolean isFunctionDefinition
) throws RecognitionException, TokenStreamException {
String declName;
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode declarator_AST = null;
Token id = null;
TNode id_AST = null;
declName = "";
try { // for error handling
{
switch ( LA(1)) {
case STAR:
{
pointerGroup();
astFactory.addASTChild(currentAST, returnAST);
break;
}
case ID:
case LPAREN:
{
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
{
switch ( LA(1)) {
case ID:
{
id = LT(1);
id_AST = (TNode)astFactory.create(id);
astFactory.addASTChild(currentAST, id_AST);
match(ID);
if ( inputState.guessing==0 ) {
declName = id.getText();
}
break;
}
case LPAREN:
{
TNode tmp17_AST = null;
tmp17_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp17_AST);
match(LPAREN);
declName=declarator(false);
astFactory.addASTChild(currentAST, returnAST);
TNode tmp18_AST = null;
tmp18_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp18_AST);
match(RPAREN);
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
{
_loop2107:
do {
switch ( LA(1)) {
case LPAREN:
{
declaratorParamaterList(isFunctionDefinition, declName);
astFactory.addASTChild(currentAST, returnAST);
break;
}
case LBRACKET:
{
TNode tmp19_AST = null;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?