stdcparser.java
来自「plugin for eclipse」· Java 代码 · 共 2,566 行 · 第 1/5 页
JAVA
2,566 行
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_26);
} else {
throw ex;
}
}
returnAST = constExpr_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;
TNode p_AST = null;
TNode i_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 tmp41_AST = null;
tmp41_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp41_AST);
match(LPAREN);
declName=declarator(false);
astFactory.addASTChild(currentAST, returnAST);
TNode tmp42_AST = null;
tmp42_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp42_AST);
match(RPAREN);
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
{
_loop1477:
do {
switch ( LA(1)) {
case LPAREN:
{
TNode tmp43_AST = null;
tmp43_AST = (TNode)astFactory.create(LT(1));
match(LPAREN);
if ( inputState.guessing==0 ) {
if (isFunctionDefinition) {
pushScope(declName);
}
else {
pushScope("!"+declName);
}
}
{
boolean synPredMatched1474 = false;
if (((_tokenSet_2.member(LA(1))) && (_tokenSet_27.member(LA(2))))) {
int _m1474 = mark();
synPredMatched1474 = true;
inputState.guessing++;
try {
{
declSpecifiers();
}
}
catch (RecognitionException pe) {
synPredMatched1474 = false;
}
rewind(_m1474);
inputState.guessing--;
}
if ( synPredMatched1474 ) {
parameterTypeList();
p_AST = (TNode)returnAST;
if ( inputState.guessing==0 ) {
declarator_AST = (TNode)currentAST.root;
declarator_AST = (TNode)astFactory.make( (new ASTArray(3)).add(null).add(declarator_AST).add((TNode)astFactory.make( (new ASTArray(2)).add((TNode)astFactory.create(NParameterTypeList)).add(p_AST))));
currentAST.root = declarator_AST;
currentAST.child = declarator_AST!=null &&declarator_AST.getFirstChild()!=null ?
declarator_AST.getFirstChild() : declarator_AST;
currentAST.advanceChildToEnd();
}
}
else if ((LA(1)==ID||LA(1)==RPAREN) && (_tokenSet_28.member(LA(2)))) {
{
switch ( LA(1)) {
case ID:
{
idList();
i_AST = (TNode)returnAST;
break;
}
case RPAREN:
{
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
if ( inputState.guessing==0 ) {
declarator_AST = (TNode)currentAST.root;
declarator_AST = (TNode)astFactory.make( (new ASTArray(3)).add(null).add(declarator_AST).add((TNode)astFactory.make( (new ASTArray(2)).add((TNode)astFactory.create(NParameterTypeList)).add(i_AST))));
currentAST.root = declarator_AST;
currentAST.child = declarator_AST!=null &&declarator_AST.getFirstChild()!=null ?
declarator_AST.getFirstChild() : declarator_AST;
currentAST.advanceChildToEnd();
}
}
else {
throw new NoViableAltException(LT(1), getFilename());
}
}
if ( inputState.guessing==0 ) {
popScope();
}
TNode tmp44_AST = null;
tmp44_AST = (TNode)astFactory.create(LT(1));
match(RPAREN);
break;
}
case LBRACKET:
{
TNode tmp45_AST = null;
tmp45_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp45_AST);
match(LBRACKET);
{
switch ( LA(1)) {
case ID:
case STAR:
case LPAREN:
case BAND:
case PLUS:
case MINUS:
case INC:
case DEC:
case LITERAL_sizeof:
case BNOT:
case LNOT:
case CharLiteral:
case StringLiteral:
case IntOctalConst:
case LongOctalConst:
case UnsignedOctalConst:
case IntIntConst:
case LongIntConst:
case UnsignedIntConst:
case IntHexConst:
case LongHexConst:
case UnsignedHexConst:
case FloatDoubleConst:
case DoubleDoubleConst:
case LongDoubleConst:
{
constExpr();
astFactory.addASTChild(currentAST, returnAST);
break;
}
case RBRACKET:
{
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
TNode tmp46_AST = null;
tmp46_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp46_AST);
match(RBRACKET);
break;
}
default:
{
break _loop1477;
}
}
} while (true);
}
if ( inputState.guessing==0 ) {
declarator_AST = (TNode)currentAST.root;
declarator_AST = (TNode)astFactory.make( (new ASTArray(2)).add((TNode)astFactory.create(NDeclarator)).add(declarator_AST));
currentAST.root = declarator_AST;
currentAST.child = declarator_AST!=null &&declarator_AST.getFirstChild()!=null ?
declarator_AST.getFirstChild() : declarator_AST;
currentAST.advanceChildToEnd();
}
declarator_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_29);
} else {
throw ex;
}
}
returnAST = declarator_AST;
return declName;
}
public final void enumList(
String enumName
) throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode enumList_AST = null;
try { // for error handling
enumerator(enumName);
astFactory.addASTChild(currentAST, returnAST);
{
_loop1446:
do {
if ((LA(1)==COMMA)) {
match(COMMA);
enumerator(enumName);
astFactory.addASTChild(currentAST, returnAST);
}
else {
break _loop1446;
}
} while (true);
}
enumList_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_21);
} else {
throw ex;
}
}
returnAST = enumList_AST;
}
public final void enumerator(
String enumName
) throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode enumerator_AST = null;
Token i = null;
TNode i_AST = null;
try { // for error handling
i = LT(1);
i_AST = (TNode)astFactory.create(i);
astFactory.addASTChild(currentAST, i_AST);
match(ID);
if ( inputState.guessing==0 ) {
symbolTable.add( i.getText(),
(TNode)astFactory.make( (new ASTArray(3)).add(null).add((TNode)astFactory.create(LITERAL_enum,"enum")).add((TNode)astFactory.create(ID,enumName)))
);
}
{
switch ( LA(1)) {
case ASSIGN:
{
TNode tmp48_AST = null;
tmp48_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp48_AST);
match(ASSIGN);
constExpr();
astFactory.addASTChild(currentAST, returnAST);
break;
}
case RCURLY:
case COMMA:
{
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
enumerator_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_30);
} else {
throw ex;
}
}
returnAST = enumerator_AST;
}
public final void initDecl(
AST declarationSpecifiers
) throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode initDecl_AST = null;
TNode d_AST = null;
String declName = "";
try { // for error handling
declName=declarator(false);
d_AST = (TNode)returnAST;
astFactory.addASTChild(currentAST, returnAST);
if ( inputState.guessing==0 ) {
AST ds1, d1;
ds1 = astFactory.dupList(declarationSpecifiers);
d1 = astFactory.dupList(d_AST);
symbolTable.add(declName, (TNode)astFactory.make( (new ASTArray(3)).add(null).add(ds1).add(d1)) );
}
{
switch ( LA(1)) {
case ASSIGN:
{
TNode tmp49_AST = null;
tmp49_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp49_AST);
match(ASSIGN);
initializer();
astFactory.addASTChild(currentAST, returnAST);
break;
}
case COLON:
{
TNode tmp50_AST = null;
tmp50_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp50_AST);
match(COLON);
expr();
astFactory.addASTChild(currentAST, returnAST);
break;
}
case SEMI:
case COMMA:
{
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
if ( inputState.guessing==0 ) {
initDecl_AST = (TNode)currentAST.root;
initDecl_AST = (TNode)astFactory.make( (new ASTArray(2)).add((TNode)astFactory.create(NInitDecl)).add(initDecl_AST));
currentAST.root = initDecl_AST;
currentAST.child = initDecl_AST!=null &&initDecl_AST.getFirstChild()!=null ?
initDecl_AST.getFirstChild() : initDecl_AST;
currentAST.advanceChildToEnd();
}
initDecl_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_25);
} else {
throw ex;
}
}
returnAST = initDecl_AST;
}
public final void initializer() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode initializer_AST = null;
try { // for error handling
{
switch ( LA(1)) {
case ID:
case STAR:
case LPAREN:
case BAND:
case PLUS:
case MINUS:
case INC:
case DEC:
case LITERAL_sizeof:
case BNOT:
case LNOT:
case CharLiteral:
case StringLiteral:
case IntOctalConst:
case LongOctalConst:
case UnsignedOctalConst:
case IntIntConst:
case LongIntConst:
case UnsignedIntConst:
case IntHexConst:
case LongHexConst:
case UnsignedHexConst:
case FloatDoubleConst:
case DoubleDoubleConst:
case LongDoubleConst:
{
assignExpr();
astFactory.addASTChild(currentAST, returnAST);
break;
}
case LCURLY:
{
TNode tmp51_AST = null;
tmp51_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp51_AST);
match(LCURLY);
initializerList();
astFactory.addASTChild(currentAST, returnAST);
{
switch ( LA(1)) {
case COMMA:
{
match(COMMA);
break;
}
case RCURLY:
{
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
match(RCURLY);
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
if ( inputState.guessing==0 ) {
initializer_AST = (TNode)currentAST.root;
initializer_AST = (TNode)astFactory.make( (new ASTArray(2)).add((TNode)astFactory.create(NInitializer)).add(initializer_AST));
currentAST.root = initializer_AST;
currentAST.child = initializer_AST!=null &&initializer_AST.getFirstChild()!=null ?
initializer_AST.getFirstChild() : initializer_AST;
currentAST.advanceChildToEnd();
}
initializer_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_31);
} else {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?