📄 nesctreeparser.java
字号:
// $ANTLR : "expandedNesCTreeParser.g" -> "NesCTreeParser.java"$
package isis.anp.nesc;
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.ASTPair;
import antlr.MismatchedTokenException;
import antlr.NoViableAltException;
import antlr.RecognitionException;
import antlr.collections.AST;
import antlr.collections.impl.BitSet;
public class NesCTreeParser extends antlr.TreeParser implements NesCTreeParserTokenTypes
{
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 NesCTreeParser() {
tokenNames = _tokenNames;
}
public final void translationUnit(AST _t) throws RecognitionException {
TNode translationUnit_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode translationUnit_AST = null;
if (_t==null) _t=ASTNULL;
switch ( _t.getType()) {
case NIncludeFile:
{
includeFile(_t);
_t = _retTree;
astFactory.addASTChild(currentAST, returnAST);
translationUnit_AST = (TNode)currentAST.root;
break;
}
case NModuleFile:
{
moduleFile(_t);
_t = _retTree;
astFactory.addASTChild(currentAST, returnAST);
translationUnit_AST = (TNode)currentAST.root;
break;
}
case NInterfaceFile:
{
interfaceFile(_t);
_t = _retTree;
astFactory.addASTChild(currentAST, returnAST);
translationUnit_AST = (TNode)currentAST.root;
break;
}
default:
{
throw new NoViableAltException(_t);
}
}
returnAST = translationUnit_AST;
_retTree = _t;
}
public final void includeFile(AST _t) throws RecognitionException {
TNode includeFile_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode includeFile_AST = null;
try { // for error handling
AST __t3450 = _t;
TNode tmp1_AST = null;
TNode tmp1_AST_in = null;
tmp1_AST = (TNode)astFactory.create((TNode)_t);
tmp1_AST_in = (TNode)_t;
astFactory.addASTChild(currentAST, tmp1_AST);
ASTPair __currentAST3450 = currentAST.copy();
currentAST.root = currentAST.child;
currentAST.child = null;
match(_t,NIncludeFile);
_t = _t.getFirstChild();
{
if (_t==null) _t=ASTNULL;
switch ( _t.getType()) {
case LITERAL_asm:
case SEMI:
case NDeclaration:
case NFunctionDef:
case NTypeMissing:
case NText:
{
externalList(_t);
_t = _retTree;
astFactory.addASTChild(currentAST, returnAST);
break;
}
case 3:
{
break;
}
default:
{
throw new NoViableAltException(_t);
}
}
}
currentAST = __currentAST3450;
_t = __t3450;
_t = _t.getNextSibling();
includeFile_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
if (_t!=null) {_t = _t.getNextSibling();}
} else {
throw ex;
}
}
returnAST = includeFile_AST;
_retTree = _t;
}
public final void moduleFile(AST _t) throws RecognitionException {
TNode moduleFile_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode moduleFile_AST = null;
try { // for error handling
AST __t3467 = _t;
TNode tmp2_AST = null;
TNode tmp2_AST_in = null;
tmp2_AST = (TNode)astFactory.create((TNode)_t);
tmp2_AST_in = (TNode)_t;
astFactory.addASTChild(currentAST, tmp2_AST);
ASTPair __currentAST3467 = currentAST.copy();
currentAST.root = currentAST.child;
currentAST.child = null;
match(_t,NModuleFile);
_t = _t.getFirstChild();
{
_loop3469:
do {
if (_t==null) _t=ASTNULL;
if ((_t.getType()==NIncludes)) {
includes(_t);
_t = _retTree;
astFactory.addASTChild(currentAST, returnAST);
}
else {
break _loop3469;
}
} while (true);
}
module(_t);
_t = _retTree;
astFactory.addASTChild(currentAST, returnAST);
currentAST = __currentAST3467;
_t = __t3467;
_t = _t.getNextSibling();
moduleFile_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
if (_t!=null) {_t = _t.getNextSibling();}
} else {
throw ex;
}
}
returnAST = moduleFile_AST;
_retTree = _t;
}
public final void interfaceFile(AST _t) throws RecognitionException {
TNode interfaceFile_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode interfaceFile_AST = null;
try { // for error handling
AST __t3453 = _t;
TNode tmp3_AST = null;
TNode tmp3_AST_in = null;
tmp3_AST = (TNode)astFactory.create((TNode)_t);
tmp3_AST_in = (TNode)_t;
astFactory.addASTChild(currentAST, tmp3_AST);
ASTPair __currentAST3453 = currentAST.copy();
currentAST.root = currentAST.child;
currentAST.child = null;
match(_t,NInterfaceFile);
_t = _t.getFirstChild();
{
_loop3455:
do {
if (_t==null) _t=ASTNULL;
if ((_t.getType()==NIncludes)) {
includes(_t);
_t = _retTree;
astFactory.addASTChild(currentAST, returnAST);
}
else {
break _loop3455;
}
} while (true);
}
interfaceDeclaration(_t);
_t = _retTree;
astFactory.addASTChild(currentAST, returnAST);
currentAST = __currentAST3453;
_t = __t3453;
_t = _t.getNextSibling();
interfaceFile_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
if (_t!=null) {_t = _t.getNextSibling();}
} else {
throw ex;
}
}
returnAST = interfaceFile_AST;
_retTree = _t;
}
public final void externalList(AST _t) throws RecognitionException {
TNode externalList_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode externalList_AST = null;
try { // for error handling
{
int _cnt3494=0;
_loop3494:
do {
if (_t==null) _t=ASTNULL;
switch ( _t.getType()) {
case LITERAL_asm:
case SEMI:
case NDeclaration:
case NFunctionDef:
case NTypeMissing:
{
externalDef(_t);
_t = _retTree;
astFactory.addASTChild(currentAST, returnAST);
break;
}
case NText:
{
textNode(_t);
_t = _retTree;
astFactory.addASTChild(currentAST, returnAST);
break;
}
default:
{
if ( _cnt3494>=1 ) { break _loop3494; } else {throw new NoViableAltException(_t);}
}
}
_cnt3494++;
} while (true);
}
externalList_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
if (_t!=null) {_t = _t.getNextSibling();}
} else {
throw ex;
}
}
returnAST = externalList_AST;
_retTree = _t;
}
public final void includes(AST _t) throws RecognitionException {
TNode includes_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode includes_AST = null;
TNode i = null;
TNode i_AST = null;
try { // for error handling
AST __t3457 = _t;
i = _t==ASTNULL ? null :(TNode)_t;
TNode i_AST_in = null;
i_AST = (TNode)astFactory.create(i);
astFactory.addASTChild(currentAST, i_AST);
ASTPair __currentAST3457 = currentAST.copy();
currentAST.root = currentAST.child;
currentAST.child = null;
match(_t,NIncludes);
_t = _t.getFirstChild();
includeFileNameList(_t);
_t = _retTree;
astFactory.addASTChild(currentAST, returnAST);
currentAST = __currentAST3457;
_t = __t3457;
_t = _t.getNextSibling();
includes_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
if (_t!=null) {_t = _t.getNextSibling();}
} else {
throw ex;
}
}
returnAST = includes_AST;
_retTree = _t;
}
public final void interfaceDeclaration(AST _t) throws RecognitionException {
TNode interfaceDeclaration_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode interfaceDeclaration_AST = null;
TNode lc = null;
TNode lc_AST = null;
TNode i = null;
TNode i_AST = null;
TNode id = null;
TNode id_AST = null;
TNode rc = null;
TNode rc_AST = null;
try { // for error handling
AST __t3465 = _t;
lc = _t==ASTNULL ? null :(TNode)_t;
TNode lc_AST_in = null;
lc_AST = (TNode)astFactory.create(lc);
astFactory.addASTChild(currentAST, lc_AST);
ASTPair __currentAST3465 = currentAST.copy();
currentAST.root = currentAST.child;
currentAST.child = null;
match(_t,NInterface);
_t = _t.getFirstChild();
i = (TNode)_t;
TNode i_AST_in = null;
i_AST = (TNode)astFactory.create(i);
astFactory.addASTChild(currentAST, i_AST);
match(_t,LITERAL_interface);
_t = _t.getNextSibling();
id = (TNode)_t;
TNode id_AST_in = null;
id_AST = (TNode)astFactory.create(id);
astFactory.addASTChild(currentAST, id_AST);
match(_t,ID);
_t = _t.getNextSibling();
declarationList(_t);
_t = _retTree;
astFactory.addASTChild(currentAST, returnAST);
rc = (TNode)_t;
TNode rc_AST_in = null;
rc_AST = (TNode)astFactory.create(rc);
astFactory.addASTChild(currentAST, rc_AST);
match(_t,RCURLY);
_t = _t.getNextSibling();
currentAST = __currentAST3465;
_t = __t3465;
_t = _t.getNextSibling();
interfaceDeclaration_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
if (_t!=null) {_t = _t.getNextSibling();}
} else {
throw ex;
}
}
returnAST = interfaceDeclaration_AST;
_retTree = _t;
}
public final void includeFileNameList(AST _t) throws RecognitionException {
TNode includeFileNameList_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode includeFileNameList_AST = null;
TNode c = null;
TNode c_AST = null;
try { // for error handling
{
includeFileName(_t);
_t = _retTree;
astFactory.addASTChild(currentAST, returnAST);
{
_loop3461:
do {
if (_t==null) _t=ASTNULL;
if ((_t.getType()==COMMA)) {
c = (TNode)_t;
TNode c_AST_in = null;
c_AST = (TNode)astFactory.create(c);
astFactory.addASTChild(currentAST, c_AST);
match(_t,COMMA);
_t = _t.getNextSibling();
includeFileName(_t);
_t = _retTree;
astFactory.addASTChild(currentAST, returnAST);
}
else {
break _loop3461;
}
} while (true);
}
}
includeFileNameList_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
if (_t!=null) {_t = _t.getNextSibling();}
} else {
throw ex;
}
}
returnAST = includeFileNameList_AST;
_retTree = _t;
}
public final void includeFileName(AST _t) throws RecognitionException {
TNode includeFileName_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode includeFileName_AST = null;
TNode i = null;
TNode i_AST = null;
try { // for error handling
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -