nescparser.java
来自「plugin for eclipse」· Java 代码 · 共 2,369 行 · 第 1/5 页
JAVA
2,369 行
tmp1_AST = (TNode)astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp1_AST);
match(LITERAL_includes);
includeFileNameList();
astFactory.addASTChild(currentAST, returnAST);
{
int _cnt2860=0;
_loop2860:
do {
if ((LA(1)==SEMI)) {
match(SEMI);
}
else {
if ( _cnt2860>=1 ) { break _loop2860; } else {throw new NoViableAltException(LT(1), getFilename());}
}
_cnt2860++;
} while (true);
}
if ( inputState.guessing==0 ) {
includes_AST = (TNode)currentAST.root;
includes_AST.setType(NIncludes);
}
includes_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_2);
} else {
throw ex;
}
}
returnAST = includes_AST;
}
public final void moduleFile() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode moduleFile_AST = null;
try { // for error handling
if ( inputState.guessing==0 ) {
// create the NModuleFile node now, so that the ASTs
// of the include files can be attached to it an attribute
TNode newRoot = (TNode)astFactory.create(NModuleFile);
ArrayList includeFileASTs = new ArrayList();
newRoot.setAttribute("includeFileASTs", includeFileASTs);
pushCurrentFileAST(newRoot);
/*
// parse tos.h if it hasn't been parsed beforeee
String inputFileName = "tos.h";
if(!getParserContext().getProcessedIncludes().containsKey(inputFileName)) {
try {
// parse include file
AST includeFileAST = parseIncludeFile(inputFileName);
// add its AST to the includeFileASTs attribute of the nesC file from where
// this include was included
includeFileASTs.add(includeFileAST);
} catch (java.io.FileNotFoundException e) {
// print File not found
System.err.println("Include file not found: " + inputFileName);
e.printStackTrace(System.err);
}
}
*/
}
{
_loop2871:
do {
if ((LA(1)==LITERAL_includes)) {
includes();
astFactory.addASTChild(currentAST, returnAST);
}
else {
break _loop2871;
}
} while (true);
}
module();
astFactory.addASTChild(currentAST, returnAST);
if ( inputState.guessing==0 ) {
moduleFile_AST = (TNode)currentAST.root;
moduleFile_AST = (TNode)astFactory.make( (new ASTArray(2)).add(popCurrentFileAST()).add(moduleFile_AST));
// ## = #( #[NModuleFile], ## );
currentAST.root = moduleFile_AST;
currentAST.child = moduleFile_AST!=null &&moduleFile_AST.getFirstChild()!=null ?
moduleFile_AST.getFirstChild() : moduleFile_AST;
currentAST.advanceChildToEnd();
}
moduleFile_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_1);
} else {
throw ex;
}
}
returnAST = moduleFile_AST;
}
public final void interfaceFile() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode interfaceFile_AST = null;
try { // for error handling
if ( inputState.guessing==0 ) {
// create the NInterfaceFile node now, so that the ASTs
// of the include files can be attached to it an attribute
TNode newRoot = (TNode)astFactory.create(NInterfaceFile);
ArrayList includeFileASTs = new ArrayList();
newRoot.setAttribute("includeFileASTs", includeFileASTs);
pushCurrentFileAST(newRoot);
/*
// parse tos.h if it hasn't been parsed beforee
String inputFileName = "tos.h";
if(!getParserContext().getProcessedIncludes().containsKey(inputFileName)) {
try {
// parse include file
AST includeFileAST = parseIncludeFile(inputFileName);
// add its AST to the includeFileASTs attribute of the nesC file from where
// this include was included
includeFileASTs.add(includeFileAST);
} catch (java.io.FileNotFoundException e) {
// print File not found
System.err.println("Include file not found: " + inputFileName);
e.printStackTrace(System.err);
}
}
*/
}
{
_loop2857:
do {
if ((LA(1)==LITERAL_includes)) {
includes();
astFactory.addASTChild(currentAST, returnAST);
}
else {
break _loop2857;
}
} while (true);
}
interfaceDeclaration();
astFactory.addASTChild(currentAST, returnAST);
if ( inputState.guessing==0 ) {
interfaceFile_AST = (TNode)currentAST.root;
interfaceFile_AST = (TNode)astFactory.make( (new ASTArray(2)).add(popCurrentFileAST()).add(interfaceFile_AST));
// ## = #( #[NInterfaceFile], ## );
currentAST.root = interfaceFile_AST;
currentAST.child = interfaceFile_AST!=null &&interfaceFile_AST.getFirstChild()!=null ?
interfaceFile_AST.getFirstChild() : interfaceFile_AST;
currentAST.advanceChildToEnd();
}
interfaceFile_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_1);
} else {
throw ex;
}
}
returnAST = interfaceFile_AST;
}
public final void configurationFile() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode configurationFile_AST = null;
try { // for error handling
if ( inputState.guessing==0 ) {
// create the NConfigurationFile node now, so that the ASTs
// of the include files can be attached to it an attribute
TNode newRoot = (TNode)astFactory.create(NConfigurationFile);
ArrayList includeFileASTs = new ArrayList();
newRoot.setAttribute("includeFileASTs", includeFileASTs);
pushCurrentFileAST(newRoot);
}
{
_loop2868:
do {
if ((LA(1)==LITERAL_includes)) {
includes();
astFactory.addASTChild(currentAST, returnAST);
}
else {
break _loop2868;
}
} while (true);
}
configuration();
astFactory.addASTChild(currentAST, returnAST);
if ( inputState.guessing==0 ) {
configurationFile_AST = (TNode)currentAST.root;
configurationFile_AST = (TNode)astFactory.make( (new ASTArray(2)).add(popCurrentFileAST()).add(configurationFile_AST));
currentAST.root = configurationFile_AST;
currentAST.child = configurationFile_AST!=null &&configurationFile_AST.getFirstChild()!=null ?
configurationFile_AST.getFirstChild() : configurationFile_AST;
currentAST.advanceChildToEnd();
}
configurationFile_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_1);
} else {
throw ex;
}
}
returnAST = configurationFile_AST;
}
public final void externalList() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode externalList_AST = null;
try { // for error handling
{
int _cnt3167=0;
_loop3167:
do {
if ((_tokenSet_3.member(LA(1)))) {
externalDef();
astFactory.addASTChild(currentAST, returnAST);
}
else {
if ( _cnt3167>=1 ) { break _loop3167; } else {throw new NoViableAltException(LT(1), getFilename());}
}
_cnt3167++;
} while (true);
}
externalList_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_4);
} else {
throw ex;
}
}
returnAST = externalList_AST;
}
public final void interfaceDeclaration() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode interfaceDeclaration_AST = null;
Token i = null;
TNode i_AST = null;
try { // for error handling
TNode tmp3_AST = null;
tmp3_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp3_AST);
match(LITERAL_interface);
i = LT(1);
i_AST = (TNode)astFactory.create(i);
astFactory.addASTChild(currentAST, i_AST);
match(ID);
TNode tmp4_AST = null;
tmp4_AST = (TNode)astFactory.create(LT(1));
astFactory.makeASTRoot(currentAST, tmp4_AST);
match(LCURLY);
declarationList();
astFactory.addASTChild(currentAST, returnAST);
TNode tmp5_AST = null;
tmp5_AST = (TNode)astFactory.create(LT(1));
astFactory.addASTChild(currentAST, tmp5_AST);
match(RCURLY);
if ( inputState.guessing==0 ) {
interfaceDeclaration_AST = (TNode)currentAST.root;
interfaceDeclaration_AST.setType(NInterface);
}
interfaceDeclaration_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_1);
} else {
throw ex;
}
}
returnAST = interfaceDeclaration_AST;
}
public final void includeFileNameList() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode includeFileNameList_AST = null;
try { // for error handling
includeFileName();
astFactory.addASTChild(currentAST, returnAST);
{
_loop2863:
do {
if ((LA(1)==COMMA)) {
match(COMMA);
includeFileName();
astFactory.addASTChild(currentAST, returnAST);
}
else {
break _loop2863;
}
} while (true);
}
includeFileNameList_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_5);
} else {
throw ex;
}
}
returnAST = includeFileNameList_AST;
}
public final void includeFileName() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode includeFileName_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 ) {
includeFileName_AST = (TNode)currentAST.root;
String inputFileName = i.getText()+".h";
// try {
// parse include file
// AST includeFileAST = parseIncludeFile(inputFileName);
AST includeFileAST = null;
ParserMessage container = new ParserMessage(ParserMessage.INFO, "Include file: "+inputFileName, new CodeLocation((CToken)i), null);
getParserContext().addMsg(container);
getParserContext().pushMessages(container);
try {
includeFileAST = getParserContext().getAST(inputFileName);
// add its AST as an attribute to the file name ID node
includeFileName_AST.setAttribute("includeFileAST", includeFileAST);
// add its AST to the includeFileASTs attribute of the nesC file from where
// this include was included
TNode currentFileAST = getCurrentFileAST();
ArrayList includeFileASTs = (ArrayList)currentFileAST.getAttribute("includeFileASTs");
includeFileASTs.add(includeFileAST);
} catch(ParserMessage m) {
getParserContext().addMsg(m);
} finally {
getParserContext().popMessages();
}
// ##.addSibling(parseIncludeFile(inputFileName));
// } catch (java.io.FileNotFoundException e) {
// print File not found
// System.err.println("Include file not found: " + inputFileName);
// e.printStackTrace(System.err);
// }
}
if ( inputState.guessing==0 ) {
includeFileName_AST = (TNode)currentAST.root;
includeFileName_AST = (TNode)astFactory.make( (new ASTArray(2)).add((TNode)astFactory.create(NIncludeFileName)).add(includeFileName_AST));
currentAST.root = includeFileName_AST;
currentAST.child = includeFileName_AST!=null &&includeFileName_AST.getFirstChild()!=null ?
includeFileName_AST.getFirstChild() : includeFileName_AST;
currentAST.advanceChildToEnd();
}
includeFileName_AST = (TNode)currentAST.root;
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
recover(ex,_tokenSet_6);
} else {
throw ex;
}
}
returnAST = includeFileName_AST;
}
public final void declarationList() throws RecognitionException, TokenStreamException {
returnAST = null;
ASTPair currentAST = new ASTPair();
TNode declarationList_AST = null;
try { // for error handling
{
int _cnt3053=0;
_loop3053:
do {
if ((LA(1)==LITERAL___label__) && (LA(2)==ID)) {
localLabelDeclaration();
astFactory.addASTChild(currentAST, returnAST);
}
else {
boolean synPredMatched3052 = false;
if (((_tokenSet_7.member(LA(1))) && (_tokenSet_8.member(LA(2))))) {
int _m3052 = mark();
synPredMatched3052 = true;
inputState.guessing++;
try {
{
declarationPredictor();
}
}
catch (RecognitionException pe) {
synPredMatched3052 = false;
}
rewind(_m3052);
inputState.guessing--;
}
if ( synPredMatched3052 ) {
declaration();
astFactory.addASTChild(currentAST, returnAST);
}
else {
if ( _cnt3053>=1 ) { break _loop3053; } else {throw new NoViableAltException(LT(1), getFilename());}
}
}
_cnt3053++;
} while (true);
}
declarationList_AST = (TNode)currentAST.root;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?