nescobjecttreebuilder.java
来自「plugin for eclipse」· Java 代码 · 共 2,529 行 · 第 1/5 页
JAVA
2,529 行
if ( inputState.guessing==0 ) {
ipObj.setNameNode(alias);
}
break;
}
case 3:
{
break;
}
default:
{
throw new NoViableAltException(_t);
}
}
}
_t = __t702;
_t = _t.getNextSibling();
if ( inputState.guessing==0 ) {
// get the AST of the interface file
TNode interfaceFileAST = (TNode)id.getAttribute("interfaceFileAST");
String interfaceFileName = id.getText()+".nc";
ParserMessage container = new ParserMessage(ParserMessage.INFO, "OT: Interface file: "+interfaceFileName, new CodeLocation(i), null);
ctx.addMsg(container);
ctx.pushMessages(container);
NesCFile nesCFileObj = null;
try {
interfaceFileObj = (NesCInterfaceFile)ctx.getObjectTree(interfaceFileName);
interfaceObj = interfaceFileObj.getInterface();
ipObj.setInterface(interfaceObj);
} catch(ParserMessage m) {
ctx.addMsg(m);
} finally {
ctx.popMessages();
}
}
{
if (_t==null) _t=ASTNULL;
switch ( _t.getType()) {
case LBRACKET:
{
ptlObj=interfaceParameters(_t);
_t = _retTree;
if ( inputState.guessing==0 ) {
portObj.setParameterTypeList(ptlObj);
}
break;
}
case 3:
case RCURLY:
case NDeclaration:
case LITERAL_interface:
{
break;
}
default:
{
throw new NoViableAltException(_t);
}
}
}
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;
return portObj;
}
public final List declaration(AST _t) throws RecognitionException {
List declnList;
TNode declaration_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
TNode dn = null;
TNode i = null;
TNode iv = null;
declnList = new ArrayList();
Declaration tmpDeclnObj = null;
Declaration declnObj = null;
StorageClassSpecifier scsObj = null;
TypeQualifier tqObj = null;
TypeSpecifier tsObj = null;
Declarator declrObj = null;
TypeBuilder tmpBuilderObj = null;
TypeBuilder builderObj = null;
Attribute attrObj = null;
try { // for error handling
AST __t747 = _t;
dn = _t==ASTNULL ? null :(TNode)_t;
match(_t,NDeclaration);
_t = _t.getFirstChild();
if ( inputState.guessing==0 ) {
tmpDeclnObj = new Declaration();
tmpDeclnObj.setDefNode(dn);
tmpBuilderObj = new TypeBuilder();
}
{
int _cnt749=0;
_loop749:
do {
if (_t==null) _t=ASTNULL;
switch ( _t.getType()) {
case LITERAL_typedef:
case LITERAL_auto:
case LITERAL_register:
case LITERAL_extern:
case LITERAL_static:
case LITERAL_default:
case LITERAL_inline:
case LITERAL_norace:
case LITERAL_async:
case LITERAL_command:
case LITERAL_event:
case LITERAL_task:
{
scsObj=storageClassSpecifier(_t);
_t = _retTree;
if ( inputState.guessing==0 ) {
tmpDeclnObj.addStorageClassSpecifier(scsObj);
}
break;
}
case LITERAL_volatile:
case LITERAL_const:
{
tqObj=typeQualifier(_t);
_t = _retTree;
if ( inputState.guessing==0 ) {
tmpBuilderObj.addTypeQualifier(tqObj);
}
break;
}
case LITERAL_struct:
case LITERAL_union:
case LITERAL_enum:
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_typeof:
case LITERAL___complex:
{
tsObj=typeSpecifier(_t);
_t = _retTree;
if ( inputState.guessing==0 ) {
//try {
tmpBuilderObj.addTypeSpecifier(tsObj);
//} catch (TypeResolutionException ex) {
// ctx.addError(new Error(ex, ex.getMessage(), new CodeLocation(tsObj.getDefNode())));
//}
}
break;
}
default:
{
if ( _cnt749>=1 ) { break _loop749; } else {throw new NoViableAltException(_t);}
}
}
_cnt749++;
} while (true);
}
{
if (_t==null) _t=ASTNULL;
switch ( _t.getType()) {
case SEMI:
{
{
int _cnt752=0;
_loop752:
do {
if (_t==null) _t=ASTNULL;
if ((_t.getType()==SEMI)) {
TNode tmp7_AST_in = (TNode)_t;
match(_t,SEMI);
_t = _t.getNextSibling();
}
else {
if ( _cnt752>=1 ) { break _loop752; } else {throw new NoViableAltException(_t);}
}
_cnt752++;
} while (true);
}
if ( inputState.guessing==0 ) {
// it seems we have a declaration without any declarators
// add the declaration to the list as it is
tmpDeclnObj.setType(tmpBuilderObj.getType());
declnList.add(tmpDeclnObj);
}
break;
}
case NInitDecl:
{
{
int _cnt758=0;
_loop758:
do {
if (_t==null) _t=ASTNULL;
if ((_t.getType()==NInitDecl)) {
AST __t754 = _t;
i = _t==ASTNULL ? null :(TNode)_t;
match(_t,NInitDecl);
_t = _t.getFirstChild();
declrObj=declarator(_t);
_t = _retTree;
if ( inputState.guessing==0 ) {
// make a copy of the temp declaration object
declnObj = (Declaration)tmpDeclnObj.clone();
builderObj = (TypeBuilder)tmpBuilderObj.clone();
try {
builderObj.addDeclarator(declrObj);
if(builderObj.getDeclarator() instanceof Declarator) {
Declarator namedDeclObj = (Declarator)builderObj.getDeclarator();
declnObj.setNameNode(namedDeclObj.getNameNode());
}
declnObj.setType(builderObj.getType());
} catch (TypeResolutionException ex) {
ctx.addMsg(new ParserMessage(ParserMessage.ERROR, ex.getMessage(), new CodeLocation(declrObj.getDefNode()), ex));
}
}
{
_loop756:
do {
if (_t==null) _t=ASTNULL;
if ((_t.getType()==NAsmAttribute||_t.getType()==LITERAL___attribute)) {
attrObj=attributeDecl(_t);
_t = _retTree;
if ( inputState.guessing==0 ) {
declnObj.addAttribute(attrObj);
}
}
else {
break _loop756;
}
} while (true);
}
{
if (_t==null) _t=ASTNULL;
switch ( _t.getType()) {
case ASSIGN:
{
TNode tmp8_AST_in = (TNode)_t;
match(_t,ASSIGN);
_t = _t.getNextSibling();
iv = _t==ASTNULL ? null : (TNode)_t;
initializer(_t);
_t = _retTree;
if ( inputState.guessing==0 ) {
declnObj.setInitializer(iv);
}
break;
}
case COLON:
{
TNode tmp9_AST_in = (TNode)_t;
match(_t,COLON);
_t = _t.getNextSibling();
expr(_t);
_t = _retTree;
break;
}
case 3:
{
break;
}
default:
{
throw new NoViableAltException(_t);
}
}
}
_t = __t754;
_t = _t.getNextSibling();
if ( inputState.guessing==0 ) {
if(declnObj.getType() instanceof FunctionType && declnObj.getName()!=null) {
declnObj = new FunctionDeclaration(declnObj);
}
declnObj.addToScope(ctx);
declnList.add(declnObj);
}
}
else {
if ( _cnt758>=1 ) { break _loop758; } else {throw new NoViableAltException(_t);}
}
_cnt758++;
} while (true);
}
{
int _cnt760=0;
_loop760:
do {
if (_t==null) _t=ASTNULL;
if ((_t.getType()==SEMI)) {
TNode tmp10_AST_in = (TNode)_t;
match(_t,SEMI);
_t = _t.getNextSibling();
}
else {
if ( _cnt760>=1 ) { break _loop760; } else {throw new NoViableAltException(_t);}
}
_cnt760++;
} while (true);
}
break;
}
default:
{
throw new NoViableAltException(_t);
}
}
}
_t = __t747;
_t = _t.getNextSibling();
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
if (_t!=null) {_t = _t.getNextSibling();}
} else {
throw ex;
}
}
_retTree = _t;
return declnList;
}
public final ParameterTypeList interfaceParameters(AST _t) throws RecognitionException {
ParameterTypeList ptlObj = null;
TNode interfaceParameters_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
TNode l = null;
TNode r = null;
try { // for error handling
l = (TNode)_t;
match(_t,LBRACKET);
_t = _t.getNextSibling();
ptlObj=parameterTypeList(_t);
_t = _retTree;
r = (TNode)_t;
match(_t,RBRACKET);
_t = _t.getNextSibling();
}
catch (RecognitionException ex) {
if (inputState.guessing==0) {
reportError(ex);
if (_t!=null) {_t = _t.getNextSibling();}
} else {
throw ex;
}
}
_retTree = _t;
return ptlObj;
}
public final ParameterTypeList parameterTypeList(AST _t) throws RecognitionException {
ParameterTypeList ptlObj;
TNode parameterTypeList_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
ptlObj = new ParameterTypeList();
ParameterDeclaration pdObj = null;
try { // for error handling
{
int _cnt866=0;
_loop866:
do {
if (_t==null) _t=ASTNULL;
if ((_t.getType()==NParameterDeclaration)) {
pdObj=parameterDeclaration(_t);
_t = _retTree;
if ( inputState.guessing==0 ) {
ptlObj.addParameterDeclaration(pdObj);
}
{
if (_t==null) _t=ASTNULL;
switch ( _t.getType()) {
case COMMA:
{
TNode tmp11_AST_in = (TNode)_t;
match(_t,COMMA);
_t = _t.getNextSibling();
break;
}
case SEMI:
{
TNode tmp12_AST_in = (TNode)_t;
match(_t,SEMI);
_t = _t.getNextSibling();
break;
}
case RPAREN:
case RBRACKET:
case VARARGS:
case NParameterDeclaration:
{
break;
}
default:
{
throw new NoViableAltException(_t);
}
}
}
}
else {
if ( _cnt866>=1 ) { break _loop866; } else {throw new NoViableAltException(_t);}
}
_cnt866++;
} while (true);
}
{
if (_t==null) _t=ASTNULL;
switch ( _t.getType()) {
case VARARGS:
{
TNode tmp13_AST_in = (TNode)_t;
match(_t,VARARGS);
_t = _t.getNextSibling();
if ( inputState.guessing==0 ) {
ptlObj.addVarArgs();
}
break;
}
case RPAREN:
case RBRACKET:
{
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;
return ptlObj;
}
public final FunctionDefinition functionDef(AST _t) throws RecognitionException {
FunctionDefinition fcnDefObj = null;
TNode functionDef_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
TNode fdn = null;
TNode tq = null;
TNode ts = null;
TNode dr = null;
Declarator declObj = null;
StorageClassSpecifier scsObj = null;
TypeQualifier tqObj = null;
TypeSpecifier tsObj = null;
CompoundStatement csObj = null;
TypeBuilder builderObj = null;
Scope scope = null;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?