gnuctreeparser.java
来自「plugin for eclipse」· Java 代码 · 共 3,123 行 · 第 1/5 页
JAVA
3,123 行
// $ANTLR : "GnuCTreeParser.g" -> "GnuCTreeParser.java"$
package isis.anp.gnuc;
import antlr.TreeParser;
import antlr.Token;
import antlr.collections.AST;
import antlr.RecognitionException;
import antlr.ANTLRException;
import antlr.NoViableAltException;
import antlr.MismatchedTokenException;
import antlr.SemanticException;
import antlr.collections.impl.BitSet;
import antlr.ASTPair;
import antlr.collections.impl.ASTArray;
import isis.anp.common.TNode;
import antlr.MismatchedTokenException;
import antlr.NoViableAltException;
import antlr.RecognitionException;
import antlr.collections.AST;
import antlr.collections.impl.BitSet;
public class GnuCTreeParser extends antlr.TreeParser implements GnuCTreeParserTokenTypes
{
int traceDepth = 0;
public void reportError(RecognitionException ex) {
if ( ex != null) {
System.err.println("ANTLR Tree Parsing RecognitionException Error: " + ex.getClass().getName() + " " + ex );
ex.printStackTrace(System.err);
}
}
public void reportError(NoViableAltException ex) {
System.err.println("ANTLR Tree Parsing NoViableAltException Error: " + ex.toString());
TNode.printTree( ex.node );
ex.printStackTrace(System.err);
}
public void reportError(MismatchedTokenException ex) {
if ( ex != null) {
TNode.printTree( ex.node );
System.err.println("ANTLR Tree Parsing MismatchedTokenException Error: " + ex );
ex.printStackTrace(System.err);
}
}
public void reportError(String s) {
System.err.println("ANTLR Error from String: " + s);
}
public void reportWarning(String s) {
System.err.println("ANTLR Warning from String: " + s);
}
protected void match(AST t, int ttype) throws MismatchedTokenException {
//System.out.println("match("+ttype+"); cursor is "+t);
super.match(t, ttype);
}
public void match(AST t, BitSet b) throws MismatchedTokenException {
//System.out.println("match("+b+"); cursor is "+t);
super.match(t, b);
}
protected void matchNot(AST t, int ttype) throws MismatchedTokenException {
//System.out.println("matchNot("+ttype+"); cursor is "+t);
super.matchNot(t, ttype);
}
public void traceIn(String rname, AST t) {
traceDepth += 1;
for (int x=0; x<traceDepth; x++) System.out.print(" ");
super.traceIn(rname, t);
}
public void traceOut(String rname, AST t) {
for (int x=0; x<traceDepth; x++) System.out.print(" ");
super.traceOut(rname, t);
traceDepth -= 1;
}
public GnuCTreeParser() {
tokenNames = _tokenNames;
}
public final void translationUnit(AST _t) throws RecognitionException {
TNode translationUnit_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
{
if (_t==null) _t=ASTNULL;
switch ( _t.getType()) {
case LITERAL_asm:
case SEMI:
case NDeclaration:
case NFunctionDef:
case NTypeMissing:
{
externalList(_t);
_t = _retTree;
break;
}
case 3:
{
break;
}
default:
{
throw new NoViableAltException(_t);
}
}
}
_retTree = _t;
}
public final void externalList(AST _t) throws RecognitionException {
TNode externalList_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
try { // for error handling
{
int _cnt1781=0;
_loop1781:
do {
if (_t==null) _t=ASTNULL;
if ((_tokenSet_0.member(_t.getType()))) {
externalDef(_t);
_t = _retTree;
}
else {
if ( _cnt1781>=1 ) { break _loop1781; } else {throw new NoViableAltException(_t);}
}
_cnt1781++;
} while (true);
}
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
if (_t!=null) {_t = _t.getNextSibling();}
} else {
throw ex;
}
}
_retTree = _t;
}
public final void externalDef(AST _t) throws RecognitionException {
TNode externalDef_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
try { // for error handling
if (_t==null) _t=ASTNULL;
switch ( _t.getType()) {
case NDeclaration:
{
declaration(_t);
_t = _retTree;
break;
}
case NFunctionDef:
{
functionDef(_t);
_t = _retTree;
break;
}
case LITERAL_asm:
{
asm_expr(_t);
_t = _retTree;
break;
}
case SEMI:
{
TNode tmp1_AST_in = (TNode)_t;
match(_t,SEMI);
_t = _t.getNextSibling();
break;
}
case NTypeMissing:
{
typelessDeclaration(_t);
_t = _retTree;
break;
}
default:
{
throw new NoViableAltException(_t);
}
}
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
if (_t!=null) {_t = _t.getNextSibling();}
} else {
throw ex;
}
}
_retTree = _t;
}
public final void declaration(AST _t) throws RecognitionException {
TNode declaration_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
try { // for error handling
AST __t1791 = _t;
TNode tmp2_AST_in = (TNode)_t;
match(_t,NDeclaration);
_t = _t.getFirstChild();
declSpecifiers(_t);
_t = _retTree;
{
if (_t==null) _t=ASTNULL;
switch ( _t.getType()) {
case NInitDecl:
{
initDeclList(_t);
_t = _retTree;
break;
}
case SEMI:
{
break;
}
default:
{
throw new NoViableAltException(_t);
}
}
}
{
int _cnt1794=0;
_loop1794:
do {
if (_t==null) _t=ASTNULL;
if ((_t.getType()==SEMI)) {
TNode tmp3_AST_in = (TNode)_t;
match(_t,SEMI);
_t = _t.getNextSibling();
}
else {
if ( _cnt1794>=1 ) { break _loop1794; } else {throw new NoViableAltException(_t);}
}
_cnt1794++;
} while (true);
}
_t = __t1791;
_t = _t.getNextSibling();
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
if (_t!=null) {_t = _t.getNextSibling();}
} else {
throw ex;
}
}
_retTree = _t;
}
public final void functionDef(AST _t) throws RecognitionException {
TNode functionDef_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
try { // for error handling
AST __t1901 = _t;
TNode tmp4_AST_in = (TNode)_t;
match(_t,NFunctionDef);
_t = _t.getFirstChild();
{
if (_t==null) _t=ASTNULL;
switch ( _t.getType()) {
case LITERAL_volatile:
case LITERAL_struct:
case LITERAL_union:
case LITERAL_enum:
case LITERAL_extern:
case LITERAL_static:
case LITERAL_const:
case LITERAL_void:
case LITERAL_char:
case LITERAL_short:
case LITERAL_int:
case LITERAL_long:
case LITERAL_float:
case LITERAL_double:
case LITERAL_signed:
case LITERAL_unsigned:
case NTypedefName:
case LITERAL_inline:
case LITERAL_typeof:
case LITERAL___complex:
{
functionDeclSpecifiers(_t);
_t = _retTree;
break;
}
case NDeclarator:
{
break;
}
default:
{
throw new NoViableAltException(_t);
}
}
}
declarator(_t);
_t = _retTree;
{
_loop1904:
do {
if (_t==null) _t=ASTNULL;
switch ( _t.getType()) {
case NDeclaration:
{
declaration(_t);
_t = _retTree;
break;
}
case VARARGS:
{
TNode tmp5_AST_in = (TNode)_t;
match(_t,VARARGS);
_t = _t.getNextSibling();
break;
}
default:
{
break _loop1904;
}
}
} while (true);
}
compoundStatement(_t);
_t = _retTree;
_t = __t1901;
_t = _t.getNextSibling();
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
if (_t!=null) {_t = _t.getNextSibling();}
} else {
throw ex;
}
}
_retTree = _t;
}
public final void asm_expr(AST _t) throws RecognitionException {
TNode asm_expr_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
try { // for error handling
AST __t1786 = _t;
TNode tmp6_AST_in = (TNode)_t;
match(_t,LITERAL_asm);
_t = _t.getFirstChild();
{
if (_t==null) _t=ASTNULL;
switch ( _t.getType()) {
case LITERAL_volatile:
{
TNode tmp7_AST_in = (TNode)_t;
match(_t,LITERAL_volatile);
_t = _t.getNextSibling();
break;
}
case LCURLY:
{
break;
}
default:
{
throw new NoViableAltException(_t);
}
}
}
TNode tmp8_AST_in = (TNode)_t;
match(_t,LCURLY);
_t = _t.getNextSibling();
expr(_t);
_t = _retTree;
TNode tmp9_AST_in = (TNode)_t;
match(_t,RCURLY);
_t = _t.getNextSibling();
{
int _cnt1789=0;
_loop1789:
do {
if (_t==null) _t=ASTNULL;
if ((_t.getType()==SEMI)) {
TNode tmp10_AST_in = (TNode)_t;
match(_t,SEMI);
_t = _t.getNextSibling();
}
else {
if ( _cnt1789>=1 ) { break _loop1789; } else {throw new NoViableAltException(_t);}
}
_cnt1789++;
} while (true);
}
_t = __t1786;
_t = _t.getNextSibling();
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
if (_t!=null) {_t = _t.getNextSibling();}
} else {
throw ex;
}
}
_retTree = _t;
}
public final void typelessDeclaration(AST _t) throws RecognitionException {
TNode typelessDeclaration_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
try { // for error handling
AST __t1784 = _t;
TNode tmp11_AST_in = (TNode)_t;
match(_t,NTypeMissing);
_t = _t.getFirstChild();
initDeclList(_t);
_t = _retTree;
TNode tmp12_AST_in = (TNode)_t;
match(_t,SEMI);
_t = _t.getNextSibling();
_t = __t1784;
_t = _t.getNextSibling();
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
if (_t!=null) {_t = _t.getNextSibling();}
} else {
throw ex;
}
}
_retTree = _t;
}
public final void initDeclList(AST _t) throws RecognitionException {
TNode initDeclList_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
try { // for error handling
{
int _cnt1854=0;
_loop1854:
do {
if (_t==null) _t=ASTNULL;
if ((_t.getType()==NInitDecl)) {
initDecl(_t);
_t = _retTree;
}
else {
if ( _cnt1854>=1 ) { break _loop1854; } else {throw new NoViableAltException(_t);}
}
_cnt1854++;
} while (true);
}
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
if (_t!=null) {_t = _t.getNextSibling();}
} else {
throw ex;
}
}
_retTree = _t;
}
public final void expr(AST _t) throws RecognitionException {
TNode expr_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
try { // for error handling
if (_t==null) _t=ASTNULL;
switch ( _t.getType()) {
case ASSIGN:
case DIV_ASSIGN:
case PLUS_ASSIGN:
case MINUS_ASSIGN:
case STAR_ASSIGN:
case MOD_ASSIGN:
case RSHIFT_ASSIGN:
case LSHIFT_ASSIGN:
case BAND_ASSIGN:
case BOR_ASSIGN:
case BXOR_ASSIGN:
{
assignExpr(_t);
_t = _retTree;
break;
}
case QUESTION:
{
conditionalExpr(_t);
_t = _retTree;
break;
}
case LOR:
{
logicalOrExpr(_t);
_t = _retTree;
break;
}
case LAND:
{
logicalAndExpr(_t);
_t = _retTree;
break;
}
case BOR:
{
inclusiveOrExpr(_t);
_t = _retTree;
break;
}
case BXOR:
{
exclusiveOrExpr(_t);
_t = _retTree;
break;
}
case BAND:
{
bitAndExpr(_t);
_t = _retTree;
break;
}
case EQUAL:
case NOT_EQUAL:
{
equalityExpr(_t);
_t = _retTree;
break;
}
case LT:
case LTE:
case GT:
case GTE:
{
relationalExpr(_t);
_t = _retTree;
break;
}
case LSHIFT:
case RSHIFT:
{
shiftExpr(_t);
_t = _retTree;
break;
}
case PLUS:
case MINUS:
{
additiveExpr(_t);
_t = _retTree;
break;
}
case STAR:
case DIV:
case MOD:
{
multExpr(_t);
_t = _retTree;
break;
}
case NCast:
{
castExpr(_t);
_t = _retTree;
break;
}
case INC:
case DEC:
case LITERAL_sizeof:
case NUnaryExpr:
case LITERAL___alignof:
{
unaryExpr(_t);
_t = _retTree;
break;
}
case NPostfixExpr:
{
postfixExpr(_t);
_t = _retTree;
break;
}
case ID:
case CharLiteral:
case NExpressionGroup:
case NStringSeq:
case Number:
{
primaryExpr(_t);
_t = _retTree;
break;
}
case NCommaExpr:
{
commaExpr(_t);
_t = _retTree;
break;
}
case NEmptyExpression:
{
emptyExpr(_t);
_t = _retTree;
break;
}
case LPAREN:
{
compoundStatementExpr(_t);
_t = _retTree;
break;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?