3 package com.jogamp.gluegen.cgram;
8 import antlr.CommonAST;
9 import com.jogamp.gluegen.ASTLocusTag;
10 import com.jogamp.gluegen.ConstantDefinition;
11 import com.jogamp.gluegen.ConstantDefinition.CNumber;
12 import com.jogamp.gluegen.GlueGenException;
13 import com.jogamp.gluegen.JavaConfiguration;
14 import com.jogamp.gluegen.cgram.types.*;
15 import com.jogamp.gluegen.cgram.types.EnumType;
16 import com.jogamp.gluegen.cgram.types.EnumType.Enumerator;
18import antlr.TreeParser;
20import antlr.collections.AST;
21import antlr.RecognitionException;
22import antlr.ANTLRException;
23import antlr.NoViableAltException;
24import antlr.MismatchedTokenException;
25import antlr.SemanticException;
26import antlr.collections.impl.BitSet;
28import antlr.collections.impl.ASTArray;
37 boolean debug =
false;
56 this.typedefDictionary = dict;
61 return typedefDictionary;
68 this.structDictionary = dict;
73 return structDictionary;
86 public void setEnums(List<EnumType> enumTypes) {
91 throw new RuntimeException(
"setEnums is Unimplemented!");
96 return new ArrayList<EnumType>(enumHash.values());
111 private CompoundType lookupInStructDictionary(String structName,
118 structDictionary.
put(structName, t);
119 debugPrintln(
"Adding compound mapping: [" + structName +
"] -> "+getDebugTypeString(t)+
" @ "+locusTag);
125 private Type lookupInTypedefDictionary(
final AST _t, String
typeName) {
128 throwGlueGenException(_t,
129 "Undefined reference to typedef name " +
typeName);
134 static class ParameterDeclaration {
138 ParameterDeclaration(String
id,
Type type) {
142 String id() {
return id; }
143 Type type() {
return type; }
144 void setType(
final Type t) { type = t; }
145 public String toString() {
return "ParamDecl["+
id+
": "+type.
getDebugString()+
"]"; }
149 static class TypeBox {
150 private Type origType;
152 private boolean isTypedef;
158 TypeBox(
Type type,
boolean isTypedef) {
159 this.origType = type;
160 this.isTypedef = isTypedef;
169 void setType(
Type type) {
176 boolean isTypedef() {
return isTypedef; }
179 public String toString() {
180 String tStr =
"Type=NULL_REF";
181 if (type == origType) {
182 tStr =
"Type=ORIG_TYPE";
183 }
else if (type !=
null) {
185 type.
getName() +
"\"; signature=\"" + type +
"\"; class " +
188 String oStr =
"OrigType=NULL_REF";
189 if (origType !=
null) {
191 origType.
getName() +
"\"; signature=\"" + origType +
"\"; class " +
194 return "<["+tStr +
"] [" + oStr +
"] " +
" isTypedef=" + isTypedef+
">";
198 private String getDebugTypeString(
Type t) {
200 return getTypeString(t);
205 private String getTypeString(
Type t) {
206 StringBuilder sb =
new StringBuilder();
210 sb.append(
", opaque ").append(isOpaque(t)).append(
"]");
214 return sb.toString();
216 private boolean isOpaque(
final Type type) {
217 return (cfg.
typeInfo(type) !=
null);
220 private void debugPrintln(String msg) {
222 System.err.println(msg);
226 private void debugPrint(String msg) {
228 System.err.print(msg);
235 private List<FunctionSymbol> functions =
new ArrayList<FunctionSymbol>();
237 private HashMap<String, EnumType> enumHash =
new HashMap<String, EnumType>();
238 private HashMap<String, EnumType> enumMap =
new HashMap<String, EnumType>();
241 private static final int AUTO = 1 << 0;
242 private static final int REGISTER = 1 << 1;
243 private static final int TYPEDEF = 1 << 2;
245 private static final int EXTERN = 1 << 3;
246 private static final int STATIC = 1 << 4;
247 private static final int INLINE = 1 << 5;
249 private static final int CONST = 1 << 6;
250 private static final int VOLATILE = 1 << 7;
251 private static final int SIGNED = 1 << 8;
252 private static final int UNSIGNED = 1 << 9;
254 private boolean isFuncDeclaration;
255 private String funcDeclName;
256 private List<ParameterDeclaration> funcDeclParams;
259 private void resetFuncDeclaration() {
260 isFuncDeclaration =
false;
262 funcDeclParams =
null;
265 private void setFuncDeclaration(
final String name,
final List<ParameterDeclaration> p,
final ASTLocusTag locusTag) {
266 isFuncDeclaration =
true;
269 funcLocusTag = locusTag;
272 private void processDeclaration(
Type returnType) {
273 if (isFuncDeclaration) {
275 new FunctionType(
null,
null, returnType, 0, funcLocusTag),
277 debugPrintln(
"Function ... "+sym.
toString()+
" @ "+funcLocusTag);
278 if (funcDeclParams !=
null) {
279 for (Iterator<ParameterDeclaration> iter = funcDeclParams.iterator(); iter.hasNext(); ) {
280 ParameterDeclaration pd = iter.next();
281 pd.setType(pd.type());
282 debugPrintln(
" add "+pd.toString());
286 debugPrintln(
"Function Added "+sym.
toString());
288 resetFuncDeclaration();
292 private int attrs2CVAttrs(
int attrs) {
294 if ((attrs & CONST) != 0) {
297 if ((attrs & VOLATILE) != 0) {
305 private void handleArrayExpr(TypeBox tb, AST t,
ASTLocusTag locusTag) {
308 final int len = parseIntConstExpr(t);
311 }
catch (RecognitionException e) {
316 tb.type(), 0, locusTag)));
319 private int parseIntConstExpr(AST t)
throws RecognitionException {
327 Iterator<EnumType> it = enumHash.values().iterator();
328 while (it.hasNext()) {
329 EnumType potentialMatch = it.next();
330 if (potentialMatch.
getName().equals(enumTypeName)) {
331 enumType = potentialMatch;
336 if (enumType ==
null) {
352 private Map<Type, Type> canonMap =
new HashMap<Type, Type>();
363 private void throwGlueGenException(
final AST t,
final String message)
throws GlueGenException {
375 private ASTLocusTag findASTLocusTag(
final AST astIn) {
378 if( ast instanceof TNode ) {
379 final TNode tn = (TNode) ast;
385 ast = ast.getFirstChild();
389 private void dumpASTTree(
final String pre,
final AST t) {
392 while(
null != it ) {
393 it = dumpAST(pre+
"."+i, it);
397 private AST dumpAST(
final String pre,
final AST ast) {
399 System.err.println(pre+
".0: AST NULL");
402 System.err.println(pre+
".0: AST Type: "+ast.getClass().getName());
403 System.err.println(pre+
".1: line:col "+ast.getLine()+
":"+ast.getColumn()+
" -> "+ast.getText());
404 if( ast instanceof TNode ) {
405 final TNode tn = (TNode) ast;
407 System.err.println(pre+
".TN.1: "+tag);
408 final Hashtable<String, Object> attributes = tn.getAttributesTable();
409 System.err.println(pre+
".TN.2: "+attributes);
411 return ast.getFirstChild();
420 )
throws RecognitionException {
423 TNode declarator_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
427 resetFuncDeclaration();
429 List<ParameterDeclaration> params =
null;
430 String funcPointerName =
null;
431 TypeBox dummyTypeBox =
null;
432 final ASTLocusTag locusTag = findASTLocusTag(declarator_AST_in);
439 _t = _t.getFirstChild();
441 if (_t==
null) _t=ASTNULL;
442 switch ( _t.getType()) {
456 throw new NoViableAltException(_t);
461 if (_t==
null) _t=ASTNULL;
462 switch ( _t.getType()) {
467 _t = _t.getNextSibling();
468 if ( inputState.guessing==0 ) {
477 _t = _t.getNextSibling();
482 _t = _t.getNextSibling();
487 throw new NoViableAltException(_t);
494 if (_t==
null) _t=ASTNULL;
495 switch ( _t.getType()) {
501 _t = _t.getFirstChild();
503 if (_t==
null) _t=ASTNULL;
504 switch ( _t.getType()) {
515 if (_t==
null) _t=ASTNULL;
516 switch ( _t.getType()) {
529 throw new NoViableAltException(_t);
537 throw new NoViableAltException(_t);
543 _t = _t.getNextSibling();
545 _t = _t.getNextSibling();
546 if ( inputState.guessing==0 ) {
549 setFuncDeclaration(
id.getText(), params, locusTag);
550 }
else if ( funcPointerName !=
null ) {
553 if (params ==
null) {
561 for (Iterator iter = params.iterator(); iter.hasNext(); ) {
562 ParameterDeclaration pd = (ParameterDeclaration) iter.next();
578 _t = _t.getNextSibling();
580 if (_t==
null) _t=ASTNULL;
581 switch ( _t.getType()) {
632 e = _t==ASTNULL ? null : (
TNode)_t;
643 throw new NoViableAltException(_t);
649 _t = _t.getNextSibling();
650 if ( inputState.guessing==0 ) {
651 handleArrayExpr(tb, e, locusTag);
663 _t = _t.getNextSibling();
665 catch (RecognitionException ex) {
666 if (inputState.guessing==0) {
668 if (_t!=
null) {_t = _t.getNextSibling();}
679 )
throws RecognitionException {
681 TNode pointerGroup_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
682 int x = 0;
int y = 0;
688 _t = _t.getFirstChild();
693 if (_t==
null) _t=ASTNULL;
694 if ((_t.getType()==
STAR)) {
697 _t = _t.getNextSibling();
698 if ( inputState.guessing==0 ) {
704 if (_t==
null) _t=ASTNULL;
708 if ( inputState.guessing==0 ) {
718 if ( inputState.guessing==0 ) {
720 debugPrintln(
"IN PTR GROUP: TB=" + tb);
725 findASTLocusTag(pointerGroup_AST_in))));
731 if ( _cnt97>=1 ) {
break _loop97; }
else {
throw new NoViableAltException(_t);}
738 _t = _t.getNextSibling();
740 catch (RecognitionException ex) {
741 if (inputState.guessing==0) {
743 if (_t!=
null) {_t = _t.getNextSibling();}
752 List<ParameterDeclaration> l;
754 TNode parameterTypeList_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
755 l =
new ArrayList<ParameterDeclaration>(); ParameterDeclaration decl =
null;
762 if (_t==
null) _t=ASTNULL;
766 if ( inputState.guessing==0 ) {
767 if (decl !=
null) { l.add(decl); }
770 if (_t==
null) _t=ASTNULL;
771 switch ( _t.getType()) {
776 _t = _t.getNextSibling();
783 _t = _t.getNextSibling();
794 throw new NoViableAltException(_t);
800 if ( _cnt21>=1 ) {
break _loop21; }
else {
throw new NoViableAltException(_t);}
807 if (_t==
null) _t=ASTNULL;
808 switch ( _t.getType()) {
813 _t = _t.getNextSibling();
822 throw new NoViableAltException(_t);
827 catch (RecognitionException ex) {
828 if (inputState.guessing==0) {
830 if (_t!=
null) {_t = _t.getNextSibling();}
839 public final void idList(AST _t)
throws RecognitionException {
841 TNode idList_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
846 _t = _t.getNextSibling();
850 if (_t==
null) _t=ASTNULL;
851 if ((_t.getType()==
COMMA)) {
854 _t = _t.getNextSibling();
857 _t = _t.getNextSibling();
866 catch (RecognitionException ex) {
867 if (inputState.guessing==0) {
869 if (_t!=
null) {_t = _t.getNextSibling();}
877 public final void expr(AST _t)
throws RecognitionException {
879 TNode expr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
882 if (_t==
null) _t=ASTNULL;
883 switch ( _t.getType()) {
1045 throw new NoViableAltException(_t);
1049 catch (RecognitionException ex) {
1050 if (inputState.guessing==0) {
1052 if (_t!=
null) {_t = _t.getNextSibling();}
1062 TNode typelessDeclaration_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
1071 _t = _t.getFirstChild();
1076 _t = _t.getNextSibling();
1078 _t = _t.getNextSibling();
1080 catch (RecognitionException ex) {
1081 if (inputState.guessing==0) {
1083 if (_t!=
null) {_t = _t.getNextSibling();}
1093 )
throws RecognitionException {
1095 TNode initDeclList_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
1102 if (_t==
null) _t=ASTNULL;
1108 if ( _cnt86>=1 ) {
break _loop86; }
else {
throw new NoViableAltException(_t);}
1115 catch (RecognitionException ex) {
1116 if (inputState.guessing==0) {
1118 if (_t!=
null) {_t = _t.getNextSibling();}
1128 TNode declaration_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
1137 _t = _t.getFirstChild();
1141 if (_t==
null) _t=ASTNULL;
1142 switch ( _t.getType()) {
1155 throw new NoViableAltException(_t);
1163 if (_t==
null) _t=ASTNULL;
1164 if ((_t.getType()==
SEMI)) {
1167 _t = _t.getNextSibling();
1170 if ( _cnt17>=1 ) {
break _loop17; }
else {
throw new NoViableAltException(_t);}
1177 _t = _t.getNextSibling();
1178 if ( inputState.guessing==0 ) {
1179 processDeclaration(tb.type());
1182 catch (RecognitionException ex) {
1183 if (inputState.guessing==0) {
1185 if (_t!=
null) {_t = _t.getNextSibling();}
1196 TNode declSpecifiers_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
1209 if (_t==
null) _t=ASTNULL;
1210 switch ( _t.getType()) {
1220 if ( inputState.guessing==0 ) {
1232 if ( inputState.guessing==0 ) {
1272 if ( _cnt33>=1 ) {
break _loop33; }
else {
throw new NoViableAltException(_t);}
1278 if ( inputState.guessing==0 ) {
1281 (x & (SIGNED | UNSIGNED)) != 0) {
1283 ((x & UNSIGNED) != 0),
1285 findASTLocusTag(declSpecifiers_AST_in));
1287 tb =
new TypeBox(t, ((x & TYPEDEF) != 0));
1291 catch (RecognitionException ex) {
1292 if (inputState.guessing==0) {
1294 if (_t!=
null) {_t = _t.getNextSibling();}
1304 ParameterDeclaration pd;
1306 TNode parameterDeclaration_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
1318 _t = _t.getFirstChild();
1322 if (_t==
null) _t=ASTNULL;
1323 switch ( _t.getType()) {
1342 throw new NoViableAltException(_t);
1347 _t = _t.getNextSibling();
1348 if ( inputState.guessing==0 ) {
1351 throwGlueGenException(parameterDeclaration_AST_in,
1352 String.format(
"Undefined type for declaration '%s'", decl));
1354 pd =
new ParameterDeclaration(decl, tb.type());
1358 catch (RecognitionException ex) {
1359 if (inputState.guessing==0) {
1361 if (_t!=
null) {_t = _t.getNextSibling();}
1372 )
throws RecognitionException {
1374 TNode nonemptyAbstractDeclarator_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
1378 final ASTLocusTag locusTag = findASTLocusTag(nonemptyAbstractDeclarator_AST_in);
1385 _t = _t.getFirstChild();
1387 if (_t==
null) _t=ASTNULL;
1388 switch ( _t.getType()) {
1396 if (_t==
null) _t=ASTNULL;
1397 switch ( _t.getType()) {
1403 _t = _t.getNextSibling();
1405 if (_t==
null) _t=ASTNULL;
1406 switch ( _t.getType()) {
1425 throw new NoViableAltException(_t);
1431 _t = _t.getNextSibling();
1440 _t = _t.getNextSibling();
1442 if (_t==
null) _t=ASTNULL;
1443 switch ( _t.getType()) {
1494 e1 = _t==ASTNULL ? null : (
TNode)_t;
1505 throw new NoViableAltException(_t);
1511 _t = _t.getNextSibling();
1513 if ( inputState.guessing==0 ) {
1514 handleArrayExpr(tb, e1, locusTag);
1534 if (_t==
null) _t=ASTNULL;
1535 switch ( _t.getType()) {
1541 _t = _t.getNextSibling();
1543 if (_t==
null) _t=ASTNULL;
1544 switch ( _t.getType()) {
1563 throw new NoViableAltException(_t);
1569 _t = _t.getNextSibling();
1578 _t = _t.getNextSibling();
1580 if (_t==
null) _t=ASTNULL;
1581 switch ( _t.getType()) {
1632 e2 = _t==ASTNULL ? null : (
TNode)_t;
1643 throw new NoViableAltException(_t);
1649 _t = _t.getNextSibling();
1651 if ( inputState.guessing==0 ) {
1652 handleArrayExpr(tb, e2, locusTag);
1658 if ( _cnt117>=1 ) {
break _loop117; }
else {
throw new NoViableAltException(_t);}
1668 throw new NoViableAltException(_t);
1673 _t = _t.getNextSibling();
1675 catch (RecognitionException ex) {
1676 if (inputState.guessing==0) {
1678 if (_t!=
null) {_t = _t.getNextSibling();}
1688 TNode functionDef_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
1697 _t = _t.getFirstChild();
1699 if (_t==
null) _t=ASTNULL;
1700 switch ( _t.getType()) {
1747 throw new NoViableAltException(_t);
1756 if (_t==
null) _t=ASTNULL;
1757 switch ( _t.getType()) {
1768 _t = _t.getNextSibling();
1781 _t = _t.getNextSibling();
1783 catch (RecognitionException ex) {
1784 if (inputState.guessing==0) {
1786 if (_t!=
null) {_t = _t.getNextSibling();}
1796 TNode functionDeclSpecifiers_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
1803 if (_t==
null) _t=ASTNULL;
1804 switch ( _t.getType()) {
1857 if ( _cnt100>=1 ) {
break _loop100; }
else {
throw new NoViableAltException(_t);}
1864 catch (RecognitionException ex) {
1865 if (inputState.guessing==0) {
1867 if (_t!=
null) {_t = _t.getNextSibling();}
1877 TNode compoundStatement_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
1883 _t = _t.getFirstChild();
1887 if (_t==
null) _t=ASTNULL;
1888 switch ( _t.getType()) {
1910 if (_t==
null) _t=ASTNULL;
1911 switch ( _t.getType()) {
1938 throw new NoViableAltException(_t);
1944 _t = _t.getNextSibling();
1946 _t = _t.getNextSibling();
1948 catch (RecognitionException ex) {
1949 if (inputState.guessing==0) {
1951 if (_t!=
null) {_t = _t.getNextSibling();}
1962 TNode storageClassSpecifier_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
1966 if (_t==
null) _t=ASTNULL;
1967 switch ( _t.getType()) {
1972 _t = _t.getNextSibling();
1973 if ( inputState.guessing==0 ) {
1982 _t = _t.getNextSibling();
1983 if ( inputState.guessing==0 ) {
1992 _t = _t.getNextSibling();
1993 if ( inputState.guessing==0 ) {
2008 throw new NoViableAltException(_t);
2012 catch (RecognitionException ex) {
2013 if (inputState.guessing==0) {
2015 if (_t!=
null) {_t = _t.getNextSibling();}
2027 TNode typeQualifier_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
2031 if (_t==
null) _t=ASTNULL;
2032 switch ( _t.getType()) {
2037 _t = _t.getNextSibling();
2038 if ( inputState.guessing==0 ) {
2047 _t = _t.getNextSibling();
2048 if ( inputState.guessing==0 ) {
2057 _t = _t.getNextSibling();
2058 if ( inputState.guessing==0 ) {
2067 _t = _t.getNextSibling();
2068 if ( inputState.guessing==0 ) {
2075 throw new NoViableAltException(_t);
2079 catch (RecognitionException ex) {
2080 if (inputState.guessing==0) {
2082 if (_t!=
null) {_t = _t.getNextSibling();}
2093 )
throws RecognitionException {
2096 TNode typeSpecifier_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
2099 int cvAttrs = attrs2CVAttrs(attributes);
2100 boolean unsig = ((attributes & UNSIGNED) != 0);
2101 final ASTLocusTag locusTag = findASTLocusTag(typeSpecifier_AST_in);
2105 if (_t==
null) _t=ASTNULL;
2106 switch ( _t.getType()) {
2111 _t = _t.getNextSibling();
2112 if ( inputState.guessing==0 ) {
2113 t =
new VoidType( cvAttrs, locusTag);
2121 _t = _t.getNextSibling();
2122 if ( inputState.guessing==0 ) {
2131 _t = _t.getNextSibling();
2132 if ( inputState.guessing==0 ) {
2141 _t = _t.getNextSibling();
2142 if ( inputState.guessing==0 ) {
2151 _t = _t.getNextSibling();
2152 if ( inputState.guessing==0 ) {
2161 _t = _t.getNextSibling();
2162 if ( inputState.guessing==0 ) {
2171 _t = _t.getNextSibling();
2172 if ( inputState.guessing==0 ) {
2181 _t = _t.getNextSibling();
2182 if ( inputState.guessing==0 ) {
2191 _t = _t.getNextSibling();
2192 if ( inputState.guessing==0 ) {
2201 _t = _t.getNextSibling();
2202 if ( inputState.guessing==0 ) {
2211 _t = _t.getNextSibling();
2212 if ( inputState.guessing==0 ) {
2221 _t = _t.getNextSibling();
2222 if ( inputState.guessing==0 ) {
2231 _t = _t.getNextSibling();
2232 if ( inputState.guessing==0 ) {
2241 _t = _t.getNextSibling();
2242 if ( inputState.guessing==0 ) {
2251 _t = _t.getNextSibling();
2252 if ( inputState.guessing==0 ) {
2261 _t = _t.getNextSibling();
2262 if ( inputState.guessing==0 ) {
2271 _t = _t.getNextSibling();
2272 if ( inputState.guessing==0 ) {
2281 _t = _t.getNextSibling();
2282 if ( inputState.guessing==0 ) {
2291 _t = _t.getNextSibling();
2292 if ( inputState.guessing==0 ) {
2301 _t = _t.getNextSibling();
2302 if ( inputState.guessing==0 ) {
2311 _t = _t.getNextSibling();
2312 if ( inputState.guessing==0 ) {
2321 _t = _t.getNextSibling();
2322 if ( inputState.guessing==0 ) {
2334 if (_t==
null) _t=ASTNULL;
2354 if (_t==
null) _t=ASTNULL;
2384 _t = _t.getFirstChild();
2387 _t = _t.getNextSibling();
2389 if (_t==
null) _t=ASTNULL;
2390 switch ( _t.getType()) {
2484 throw new NoViableAltException(_t);
2490 _t = _t.getNextSibling();
2492 _t = _t.getNextSibling();
2499 _t = _t.getNextSibling();
2504 throw new NoViableAltException(_t);
2508 catch (RecognitionException ex) {
2509 if (inputState.guessing==0) {
2511 if (_t!=
null) {_t = _t.getNextSibling();}
2523 TNode functionStorageClassSpecifier_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
2527 if (_t==
null) _t=ASTNULL;
2528 switch ( _t.getType()) {
2533 _t = _t.getNextSibling();
2534 if ( inputState.guessing==0 ) {
2543 _t = _t.getNextSibling();
2544 if ( inputState.guessing==0 ) {
2553 _t = _t.getNextSibling();
2554 if ( inputState.guessing==0 ) {
2561 throw new NoViableAltException(_t);
2565 catch (RecognitionException ex) {
2566 if (inputState.guessing==0) {
2568 if (_t!=
null) {_t = _t.getNextSibling();}
2579 )
throws RecognitionException {
2582 TNode structSpecifier_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
2589 _t = _t.getFirstChild();
2593 _t = _t.getNextSibling();
2595 catch (RecognitionException ex) {
2596 if (inputState.guessing==0) {
2598 if (_t!=
null) {_t = _t.getNextSibling();}
2609 TNode attributeDecl_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
2612 if (_t==
null) _t=ASTNULL;
2613 switch ( _t.getType()) {
2619 _t = _t.getFirstChild();
2623 if (_t==
null) _t=ASTNULL;
2626 if ( _t==
null )
throw new MismatchedTokenException();
2627 _t = _t.getNextSibling();
2636 _t = _t.getNextSibling();
2644 _t = _t.getFirstChild();
2647 _t = _t.getNextSibling();
2652 _t = _t.getNextSibling();
2654 _t = _t.getNextSibling();
2659 throw new NoViableAltException(_t);
2663 catch (RecognitionException ex) {
2664 if (inputState.guessing==0) {
2666 if (_t!=
null) {_t = _t.getNextSibling();}
2676 )
throws RecognitionException {
2679 TNode unionSpecifier_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
2686 _t = _t.getFirstChild();
2690 _t = _t.getNextSibling();
2692 catch (RecognitionException ex) {
2693 if (inputState.guessing==0) {
2695 if (_t!=
null) {_t = _t.getNextSibling();}
2706 )
throws RecognitionException {
2709 TNode enumSpecifier_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
2714 ASTLocusTag locusTag = findASTLocusTag(enumSpecifier_AST_in);
2721 _t = _t.getFirstChild();
2723 boolean synPredMatched78 =
false;
2724 if (_t==
null) _t=ASTNULL;
2725 if (((_t.getType()==
ID))) {
2727 synPredMatched78 =
true;
2728 inputState.guessing++;
2733 _t = _t.getNextSibling();
2736 _t = _t.getNextSibling();
2739 catch (RecognitionException pe) {
2740 synPredMatched78 =
false;
2743inputState.guessing--;
2745 if ( synPredMatched78 ) {
2748 _t = _t.getNextSibling();
2751 _t = _t.getNextSibling();
2756 _t = _t.getNextSibling();
2758 else if ((_t.getType()==
LCURLY)) {
2761 _t = _t.getNextSibling();
2766 _t = _t.getNextSibling();
2768 else if ((_t.getType()==
ID)) {
2771 _t = _t.getNextSibling();
2772 if ( inputState.guessing==0 ) {
2773 e = getEnumType(i.
getText(), locusTag);
2777 throw new NoViableAltException(_t);
2781 if ( inputState.guessing==0 ) {
2783 debugPrintln(
"Adding enum mapping: "+getDebugTypeString(e));
2785 final String eName = e.
getName();
2787 final EnumType dupE = enumMap.get(eName);
2789 throwGlueGenException(enumSpecifier_AST_in,
2790 String.format(
"Duplicate enum w/ incompatible type:%n this '%s',%n have '%s',%n %s: previous definition is here",
2791 getTypeString(e), getTypeString(dupE), dupE.
getASTLocusTag().
toString(
new StringBuilder(),
"note",
true)));
2800 _t = _t.getNextSibling();
2802 catch (RecognitionException ex) {
2803 if (inputState.guessing==0) {
2805 if (_t!=
null) {_t = _t.getNextSibling();}
2816 )
throws RecognitionException {
2819 TNode typedefName_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
2827 _t = _t.getFirstChild();
2830 _t = _t.getNextSibling();
2832 _t = _t.getNextSibling();
2833 if ( inputState.guessing==0 ) {
2835 final Type t0 = lookupInTypedefDictionary(typedefName_AST_in,
id.getText());
2836 debugPrint(
"Adding typedef lookup: [" +
id.getText() +
"] -> "+getDebugTypeString(t0));
2838 debugPrintln(
" - cvvar -> "+getDebugTypeString(t1));
2839 t = canonicalize(t1);
2840 debugPrintln(
" - canon -> "+getDebugTypeString(t));
2844 catch (RecognitionException ex) {
2845 if (inputState.guessing==0) {
2847 if (_t!=
null) {_t = _t.getNextSibling();}
2856 public final void typeName(AST _t)
throws RecognitionException {
2858 TNode typeName_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
2867 if (_t==
null) _t=ASTNULL;
2868 switch ( _t.getType()) {
2881 throw new NoViableAltException(_t);
2886 catch (RecognitionException ex) {
2887 if (inputState.guessing==0) {
2889 if (_t!=
null) {_t = _t.getNextSibling();}
2899 )
throws RecognitionException {
2902 TNode structOrUnionBody_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
2907 boolean addedAny =
false;
2908 final ASTLocusTag locusTag = findASTLocusTag(structOrUnionBody_AST_in);
2913 boolean synPredMatched55 =
false;
2914 if (_t==
null) _t=ASTNULL;
2915 if (((_t.getType()==
ID))) {
2917 synPredMatched55 =
true;
2918 inputState.guessing++;
2923 _t = _t.getNextSibling();
2926 _t = _t.getNextSibling();
2929 catch (RecognitionException pe) {
2930 synPredMatched55 =
false;
2933inputState.guessing--;
2935 if ( synPredMatched55 ) {
2938 _t = _t.getNextSibling();
2941 _t = _t.getNextSibling();
2942 if ( inputState.guessing==0 ) {
2945 t = (
CompoundType) canonicalize(lookupInStructDictionary(
id.getText(), kind, cvAttrs, locusTag));
2949 if (_t==
null) _t=ASTNULL;
2950 switch ( _t.getType()) {
2994 throw new NoViableAltException(_t);
3000 _t = _t.getNextSibling();
3001 if ( inputState.guessing==0 ) {
3005 else if ((_t.getType()==
LCURLY)) {
3008 _t = _t.getNextSibling();
3009 if ( inputState.guessing==0 ) {
3016 if (_t==
null) _t=ASTNULL;
3017 switch ( _t.getType()) {
3061 throw new NoViableAltException(_t);
3067 _t = _t.getNextSibling();
3068 if ( inputState.guessing==0 ) {
3072 else if ((_t.getType()==
ID)) {
3075 _t = _t.getNextSibling();
3076 if ( inputState.guessing==0 ) {
3079 t = (
CompoundType) canonicalize(lookupInStructDictionary(id2.
getText(), kind, cvAttrs, locusTag));
3084 throw new NoViableAltException(_t);
3088 if ( inputState.guessing==0 ) {
3090 debugPrintln(
"Adding compound body: [" + t.
getName() +
"] -> "+getDebugTypeString(t)+
" @ "+locusTag);
3095 catch (RecognitionException ex) {
3096 if (inputState.guessing==0) {
3098 if (_t!=
null) {_t = _t.getNextSibling();}
3109 )
throws RecognitionException {
3112 TNode structDeclarationList_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
3115 boolean addedOne =
false;
3123 if (_t==
null) _t=ASTNULL;
3127 if ( inputState.guessing==0 ) {
3128 addedAny |= addedOne;
3132 if ( _cnt60>=1 ) {
break _loop60; }
else {
throw new NoViableAltException(_t);}
3139 catch (RecognitionException ex) {
3140 if (inputState.guessing==0) {
3142 if (_t!=
null) {_t = _t.getNextSibling();}
3153 )
throws RecognitionException {
3156 TNode structDeclaration_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
3167 if ( inputState.guessing==0 ) {
3173 throwGlueGenException(structDeclaration_AST_in,
3174 String.format(
"Anonymous compound, w/ NULL type:%n containing '%s'",
3175 getTypeString(containingType)));
3179 containingType.addField(
new Field(
null, t,
null));
3186 catch (RecognitionException ex) {
3187 if (inputState.guessing==0) {
3189 if (_t!=
null) {_t = _t.getNextSibling();}
3201 TNode specifierQualifierList_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
3203 t =
null;
int x = 0;
int y = 0;
3211 if (_t==
null) _t=ASTNULL;
3212 switch ( _t.getType()) {
3253 if ( inputState.guessing==0 ) {
3260 if ( _cnt64>=1 ) {
break _loop64; }
else {
throw new NoViableAltException(_t);}
3266 if ( inputState.guessing==0 ) {
3269 (x & (SIGNED | UNSIGNED)) != 0) {
3271 findASTLocusTag(specifierQualifierList_AST_in));
3276 catch (RecognitionException ex) {
3277 if (inputState.guessing==0) {
3279 if (_t!=
null) {_t = _t.getNextSibling();}
3290 )
throws RecognitionException {
3293 TNode structDeclaratorList_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
3304 if (_t==
null) _t=ASTNULL;
3308 if ( inputState.guessing==0 ) {
3313 if ( _cnt67>=1 ) {
break _loop67; }
else {
throw new NoViableAltException(_t);}
3320 catch (RecognitionException ex) {
3321 if (inputState.guessing==0) {
3323 if (_t!=
null) {_t = _t.getNextSibling();}
3334 )
throws RecognitionException {
3337 TNode structDeclarator_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
3341 TypeBox tb =
new TypeBox(t);
3348 _t = _t.getFirstChild();
3350 if (_t==
null) _t=ASTNULL;
3351 switch ( _t.getType()) {
3356 if ( inputState.guessing==0 ) {
3357 containingType.addField(
new Field(s, tb.type(),
null)); addedAny =
true;
3370 throw new NoViableAltException(_t);
3375 if (_t==
null) _t=ASTNULL;
3376 switch ( _t.getType()) {
3381 _t = _t.getNextSibling();
3384 if ( inputState.guessing==0 ) {
3397 throw new NoViableAltException(_t);
3404 if (_t==
null) _t=ASTNULL;
3416 _t = _t.getNextSibling();
3418 catch (RecognitionException ex) {
3419 if (inputState.guessing==0) {
3421 if (_t!=
null) {_t = _t.getNextSibling();}
3432 )
throws RecognitionException {
3434 TNode enumList_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
3444 if (_t==
null) _t=ASTNULL;
3445 if ((_t.getType()==
ID)) {
3446 defEnumerant=
enumerator(_t,enumeration, defEnumerant);
3450 if ( _cnt81>=1 ) {
break _loop81; }
else {
throw new NoViableAltException(_t);}
3457 catch (RecognitionException ex) {
3458 if (inputState.guessing==0) {
3460 if (_t!=
null) {_t = _t.getNextSibling();}
3470 )
throws RecognitionException {
3473 TNode enumerator_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
3477 newDefaultValue = defaultValue;
3483 _t = _t.getNextSibling();
3485 if (_t==
null) _t=ASTNULL;
3486 switch ( _t.getType()) {
3491 _t = _t.getNextSibling();
3492 eVal = _t==ASTNULL ? null : (
TNode)_t;
3504 throw new NoViableAltException(_t);
3508 if ( inputState.guessing==0 ) {
3510 final String eTxt = eName.
getText();
3514 if (enumHash.containsKey(vTxt)) {
3515 EnumType oldEnumType = enumHash.get(vTxt);
3521 }
else if( defaultValue.hasNumber() ) {
3522 newEnum =
new Enumerator(eTxt, defaultValue.getNumber());
3524 newEnum =
new Enumerator(eTxt, defaultValue.getNativeExpr());
3526 final ASTLocusTag locus = findASTLocusTag(enumerator_AST_in);
3528 if(
null != newEnumNum && newEnumNum.
isInteger ) {
3529 final long n = newEnumNum.
i+1;
3534 if (enumHash.containsKey(eTxt)) {
3535 EnumType oldEnumType = enumHash.get(eTxt);
3537 final String oldExpr = oldEnum.
getExpr();
3538 if( !oldExpr.equals(newEnum.
getExpr()) ) {
3539 throwGlueGenException(enumerator_AST_in,
3540 String.format(
"Duplicate enum value '%s.%s' w/ diff value:%n this %s,%n have %s",
3541 oldEnumType.
getName(), eTxt, newEnum, oldEnum));
3547 enumeration.addEnum(eTxt, newEnum);
3548 enumHash.put(eTxt, enumeration);
3549 debugPrintln(
"ENUM [" + enumeration.getName() +
"]: " + eTxt +
" = " + newEnum +
3550 " (new default = " + newDefaultValue +
")");
3554 catch (RecognitionException ex) {
3555 if (inputState.guessing==0) {
3557 if (_t!=
null) {_t = _t.getNextSibling();}
3563 return newDefaultValue;
3568 )
throws RecognitionException {
3570 TNode initDecl_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
3572 String declName =
null;
3573 final ASTLocusTag locusTag = findASTLocusTag(initDecl_AST_in);
3580 _t = _t.getFirstChild();
3583 if ( inputState.guessing==0 ) {
3585 debugPrintln(
"GOT declName: " + declName +
" TB=" + tb);
3591 if (_t==
null) _t=ASTNULL;
3603 if (_t==
null) _t=ASTNULL;
3604 switch ( _t.getType()) {
3609 _t = _t.getNextSibling();
3618 _t = _t.getNextSibling();
3629 throw new NoViableAltException(_t);
3634 _t = _t.getNextSibling();
3635 if ( inputState.guessing==0 ) {
3637 if ((declName !=
null) && (tb !=
null) && tb.isTypedef()) {
3639 debugPrintln(
"Adding typedef mapping: [" + declName +
"] -> "+getDebugTypeString(t));
3643 debugPrintln(
" - has target: "+getDebugTypeString(tg));
3649 if (!t.isTypedef()) {
3654 debugPrintln(
" - alias.11 -> "+getDebugTypeString(t));
3657 t = t.
clone(locusTag);
3659 debugPrintln(
" - newdefine.12 -> "+getDebugTypeString(t));
3667 debugPrintln(
" - alias.21 -> "+getDebugTypeString(t));
3670 t = t.
clone(locusTag);
3672 debugPrintln(
" - copy.22 -> "+getDebugTypeString(t));
3675 final Type dupT = typedefDictionary.
get(declName);
3677 throwGlueGenException(locusTag,
3678 String.format(
"Duplicate typedef w/ incompatible type:%n this '%s',%n have '%s',%n %s: previous definition is here",
3679 getTypeString(t), getTypeString(dupT), dupT.
getASTLocusTag().
toString(
new StringBuilder(),
"note",
true)));
3681 t = canonicalize(t);
3682 debugPrintln(
" - canon -> "+getDebugTypeString(t));
3683 typedefDictionary.
put(declName, t);
3690 catch (RecognitionException ex) {
3691 if (inputState.guessing==0) {
3693 if (_t!=
null) {_t = _t.getNextSibling();}
3703 TNode initializer_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
3706 if (_t==
null) _t=ASTNULL;
3707 switch ( _t.getType()) {
3713 _t = _t.getFirstChild();
3715 if (_t==
null) _t=ASTNULL;
3716 switch ( _t.getType()) {
3777 throw new NoViableAltException(_t);
3784 _t = _t.getNextSibling();
3795 throw new NoViableAltException(_t);
3799 catch (RecognitionException ex) {
3800 if (inputState.guessing==0) {
3802 if (_t!=
null) {_t = _t.getNextSibling();}
3813 TNode intConstExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
3819 if (_t==
null) _t=ASTNULL;
3820 switch ( _t.getType()) {
3825 _t = _t.getNextSibling();
3826 if ( inputState.guessing==0 ) {
3827 return Integer.parseInt(n.
getText());
3835 _t = _t.getNextSibling();
3836 if ( inputState.guessing==0 ) {
3838 final String enumName = e.
getText();
3839 final EnumType enumType = enumHash.get(enumName);
3840 if(
null == enumType ) {
3841 throwGlueGenException(intConstExpr_AST_in,
3842 "Error: intConstExpr ID "+enumName+
" recognized, but no containing enum-type found");
3847 debugPrintln(
"INFO: intConstExpr: enum[Type "+enumType.
getName()+
", "+
enumerator+
"]");
3849 throwGlueGenException(intConstExpr_AST_in,
3850 "Error: intConstExpr ID "+enumName+
" enum "+
enumerator+
" not an int32_t");
3852 return (
int)number.
i;
3859 throw new NoViableAltException(_t);
3863 catch (RecognitionException ex) {
3864 if (inputState.guessing==0) {
3866 if (_t!=
null) {_t = _t.getNextSibling();}
3877 TNode translationUnit_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
3880 if (_t==
null) _t=ASTNULL;
3881 switch ( _t.getType()) {
3898 throw new NoViableAltException(_t);
3907 TNode externalList_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
3914 if (_t==
null) _t=ASTNULL;
3920 if ( _cnt123>=1 ) {
break _loop123; }
else {
throw new NoViableAltException(_t);}
3927 catch (RecognitionException ex) {
3928 if (inputState.guessing==0) {
3930 if (_t!=
null) {_t = _t.getNextSibling();}
3940 TNode externalDef_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
3943 if (_t==
null) _t=ASTNULL;
3944 switch ( _t.getType()) {
3967 _t = _t.getNextSibling();
3978 throw new NoViableAltException(_t);
3982 catch (RecognitionException ex) {
3983 if (inputState.guessing==0) {
3985 if (_t!=
null) {_t = _t.getNextSibling();}
3993 public final void asm_expr(AST _t)
throws RecognitionException {
3995 TNode asm_expr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
4001 _t = _t.getFirstChild();
4003 if (_t==
null) _t=ASTNULL;
4004 switch ( _t.getType()) {
4009 _t = _t.getNextSibling();
4018 throw new NoViableAltException(_t);
4024 _t = _t.getNextSibling();
4029 _t = _t.getNextSibling();
4034 if (_t==
null) _t=ASTNULL;
4035 if ((_t.getType()==
SEMI)) {
4038 _t = _t.getNextSibling();
4041 if ( _cnt129>=1 ) {
break _loop129; }
else {
throw new NoViableAltException(_t);}
4048 _t = _t.getNextSibling();
4050 catch (RecognitionException ex) {
4051 if (inputState.guessing==0) {
4053 if (_t!=
null) {_t = _t.getNextSibling();}
4063 TNode initializerElementLabel_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
4069 _t = _t.getFirstChild();
4071 if (_t==
null) _t=ASTNULL;
4072 switch ( _t.getType()) {
4078 _t = _t.getNextSibling();
4083 _t = _t.getNextSibling();
4085 if (_t==
null) _t=ASTNULL;
4086 switch ( _t.getType()) {
4091 _t = _t.getNextSibling();
4100 throw new NoViableAltException(_t);
4111 _t = _t.getNextSibling();
4114 _t = _t.getNextSibling();
4121 _t = _t.getNextSibling();
4124 _t = _t.getNextSibling();
4127 _t = _t.getNextSibling();
4132 throw new NoViableAltException(_t);
4137 _t = _t.getNextSibling();
4139 catch (RecognitionException ex) {
4140 if (inputState.guessing==0) {
4142 if (_t!=
null) {_t = _t.getNextSibling();}
4152 TNode lcurlyInitializer_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
4158 _t = _t.getFirstChild();
4163 _t = _t.getNextSibling();
4165 _t = _t.getNextSibling();
4167 catch (RecognitionException ex) {
4168 if (inputState.guessing==0) {
4170 if (_t!=
null) {_t = _t.getNextSibling();}
4180 TNode initializerList_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
4186 if (_t==
null) _t=ASTNULL;
4198 catch (RecognitionException ex) {
4199 if (inputState.guessing==0) {
4201 if (_t!=
null) {_t = _t.getNextSibling();}
4211 TNode declarationList_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
4218 if (_t==
null) _t=ASTNULL;
4228 if ( _cnt153>=1 ) {
break _loop153; }
else {
throw new NoViableAltException(_t);}
4235 catch (RecognitionException ex) {
4236 if (inputState.guessing==0) {
4238 if (_t!=
null) {_t = _t.getNextSibling();}
4248 TNode localLabelDecl_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
4254 _t = _t.getFirstChild();
4259 if (_t==
null) _t=ASTNULL;
4260 if ((_t.getType()==
ID)) {
4263 _t = _t.getNextSibling();
4266 if ( _cnt157>=1 ) {
break _loop157; }
else {
throw new NoViableAltException(_t);}
4273 _t = _t.getNextSibling();
4275 catch (RecognitionException ex) {
4276 if (inputState.guessing==0) {
4278 if (_t!=
null) {_t = _t.getNextSibling();}
4288 TNode statementList_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
4295 if (_t==
null) _t=ASTNULL;
4301 if ( _cnt165>=1 ) {
break _loop165; }
else {
throw new NoViableAltException(_t);}
4308 catch (RecognitionException ex) {
4309 if (inputState.guessing==0) {
4311 if (_t!=
null) {_t = _t.getNextSibling();}
4319 public final void statement(AST _t)
throws RecognitionException {
4321 TNode statement_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
4327 catch (RecognitionException ex) {
4328 if (inputState.guessing==0) {
4330 if (_t!=
null) {_t = _t.getNextSibling();}
4340 TNode statementBody_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
4343 if (_t==
null) _t=ASTNULL;
4344 switch ( _t.getType()) {
4349 _t = _t.getNextSibling();
4363 _t = _t.getFirstChild();
4367 _t = _t.getNextSibling();
4375 _t = _t.getFirstChild();
4381 _t = _t.getNextSibling();
4389 _t = _t.getFirstChild();
4395 _t = _t.getNextSibling();
4403 _t = _t.getFirstChild();
4413 _t = _t.getNextSibling();
4421 _t = _t.getFirstChild();
4425 _t = _t.getNextSibling();
4432 _t = _t.getNextSibling();
4439 _t = _t.getNextSibling();
4447 _t = _t.getFirstChild();
4449 if (_t==
null) _t=ASTNULL;
4450 switch ( _t.getType()) {
4511 throw new NoViableAltException(_t);
4516 _t = _t.getNextSibling();
4524 _t = _t.getFirstChild();
4527 _t = _t.getNextSibling();
4529 if (_t==
null) _t=ASTNULL;
4530 switch ( _t.getType()) {
4557 throw new NoViableAltException(_t);
4562 _t = _t.getNextSibling();
4570 _t = _t.getFirstChild();
4574 if (_t==
null) _t=ASTNULL;
4575 switch ( _t.getType()) {
4602 throw new NoViableAltException(_t);
4607 _t = _t.getNextSibling();
4615 _t = _t.getFirstChild();
4617 if (_t==
null) _t=ASTNULL;
4618 switch ( _t.getType()) {
4645 throw new NoViableAltException(_t);
4650 _t = _t.getNextSibling();
4658 _t = _t.getFirstChild();
4664 if (_t==
null) _t=ASTNULL;
4665 switch ( _t.getType()) {
4670 _t = _t.getNextSibling();
4681 throw new NoViableAltException(_t);
4686 _t = _t.getNextSibling();
4694 _t = _t.getFirstChild();
4700 _t = _t.getNextSibling();
4705 throw new NoViableAltException(_t);
4709 catch (RecognitionException ex) {
4710 if (inputState.guessing==0) {
4712 if (_t!=
null) {_t = _t.getNextSibling();}
4720 public final void assignExpr(AST _t)
throws RecognitionException {
4722 TNode assignExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
4725 if (_t==
null) _t=ASTNULL;
4726 switch ( _t.getType()) {
4732 _t = _t.getFirstChild();
4738 _t = _t.getNextSibling();
4746 _t = _t.getFirstChild();
4752 _t = _t.getNextSibling();
4760 _t = _t.getFirstChild();
4766 _t = _t.getNextSibling();
4774 _t = _t.getFirstChild();
4780 _t = _t.getNextSibling();
4788 _t = _t.getFirstChild();
4794 _t = _t.getNextSibling();
4802 _t = _t.getFirstChild();
4808 _t = _t.getNextSibling();
4816 _t = _t.getFirstChild();
4822 _t = _t.getNextSibling();
4830 _t = _t.getFirstChild();
4836 _t = _t.getNextSibling();
4844 _t = _t.getFirstChild();
4850 _t = _t.getNextSibling();
4858 _t = _t.getFirstChild();
4864 _t = _t.getNextSibling();
4872 _t = _t.getFirstChild();
4878 _t = _t.getNextSibling();
4883 throw new NoViableAltException(_t);
4887 catch (RecognitionException ex) {
4888 if (inputState.guessing==0) {
4890 if (_t!=
null) {_t = _t.getNextSibling();}
4900 TNode conditionalExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
4906 _t = _t.getFirstChild();
4910 if (_t==
null) _t=ASTNULL;
4911 switch ( _t.getType()) {
4972 throw new NoViableAltException(_t);
4978 _t = _t.getNextSibling();
4982 _t = _t.getNextSibling();
4984 catch (RecognitionException ex) {
4985 if (inputState.guessing==0) {
4987 if (_t!=
null) {_t = _t.getNextSibling();}
4997 TNode logicalOrExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5003 _t = _t.getFirstChild();
5009 _t = _t.getNextSibling();
5011 catch (RecognitionException ex) {
5012 if (inputState.guessing==0) {
5014 if (_t!=
null) {_t = _t.getNextSibling();}
5024 TNode logicalAndExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5030 _t = _t.getFirstChild();
5036 _t = _t.getNextSibling();
5038 catch (RecognitionException ex) {
5039 if (inputState.guessing==0) {
5041 if (_t!=
null) {_t = _t.getNextSibling();}
5051 TNode inclusiveOrExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5057 _t = _t.getFirstChild();
5063 _t = _t.getNextSibling();
5065 catch (RecognitionException ex) {
5066 if (inputState.guessing==0) {
5068 if (_t!=
null) {_t = _t.getNextSibling();}
5078 TNode exclusiveOrExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5084 _t = _t.getFirstChild();
5090 _t = _t.getNextSibling();
5092 catch (RecognitionException ex) {
5093 if (inputState.guessing==0) {
5095 if (_t!=
null) {_t = _t.getNextSibling();}
5103 public final void bitAndExpr(AST _t)
throws RecognitionException {
5105 TNode bitAndExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5111 _t = _t.getFirstChild();
5117 _t = _t.getNextSibling();
5119 catch (RecognitionException ex) {
5120 if (inputState.guessing==0) {
5122 if (_t!=
null) {_t = _t.getNextSibling();}
5132 TNode equalityExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5135 if (_t==
null) _t=ASTNULL;
5136 switch ( _t.getType()) {
5142 _t = _t.getFirstChild();
5148 _t = _t.getNextSibling();
5156 _t = _t.getFirstChild();
5162 _t = _t.getNextSibling();
5167 throw new NoViableAltException(_t);
5171 catch (RecognitionException ex) {
5172 if (inputState.guessing==0) {
5174 if (_t!=
null) {_t = _t.getNextSibling();}
5184 TNode relationalExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5187 if (_t==
null) _t=ASTNULL;
5188 switch ( _t.getType()) {
5194 _t = _t.getFirstChild();
5200 _t = _t.getNextSibling();
5208 _t = _t.getFirstChild();
5214 _t = _t.getNextSibling();
5222 _t = _t.getFirstChild();
5228 _t = _t.getNextSibling();
5236 _t = _t.getFirstChild();
5242 _t = _t.getNextSibling();
5247 throw new NoViableAltException(_t);
5251 catch (RecognitionException ex) {
5252 if (inputState.guessing==0) {
5254 if (_t!=
null) {_t = _t.getNextSibling();}
5262 public final void shiftExpr(AST _t)
throws RecognitionException {
5264 TNode shiftExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5267 if (_t==
null) _t=ASTNULL;
5268 switch ( _t.getType()) {
5274 _t = _t.getFirstChild();
5280 _t = _t.getNextSibling();
5288 _t = _t.getFirstChild();
5294 _t = _t.getNextSibling();
5299 throw new NoViableAltException(_t);
5303 catch (RecognitionException ex) {
5304 if (inputState.guessing==0) {
5306 if (_t!=
null) {_t = _t.getNextSibling();}
5316 TNode additiveExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5319 if (_t==
null) _t=ASTNULL;
5320 switch ( _t.getType()) {
5326 _t = _t.getFirstChild();
5332 _t = _t.getNextSibling();
5340 _t = _t.getFirstChild();
5346 _t = _t.getNextSibling();
5351 throw new NoViableAltException(_t);
5355 catch (RecognitionException ex) {
5356 if (inputState.guessing==0) {
5358 if (_t!=
null) {_t = _t.getNextSibling();}
5366 public final void multExpr(AST _t)
throws RecognitionException {
5368 TNode multExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5371 if (_t==
null) _t=ASTNULL;
5372 switch ( _t.getType()) {
5378 _t = _t.getFirstChild();
5384 _t = _t.getNextSibling();
5392 _t = _t.getFirstChild();
5398 _t = _t.getNextSibling();
5406 _t = _t.getFirstChild();
5412 _t = _t.getNextSibling();
5417 throw new NoViableAltException(_t);
5421 catch (RecognitionException ex) {
5422 if (inputState.guessing==0) {
5424 if (_t!=
null) {_t = _t.getNextSibling();}
5432 public final void castExpr(AST _t)
throws RecognitionException {
5434 TNode castExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5440 _t = _t.getFirstChild();
5445 _t = _t.getNextSibling();
5449 _t = _t.getNextSibling();
5451 catch (RecognitionException ex) {
5452 if (inputState.guessing==0) {
5454 if (_t!=
null) {_t = _t.getNextSibling();}
5462 public final void unaryExpr(AST _t)
throws RecognitionException {
5464 TNode unaryExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5467 if (_t==
null) _t=ASTNULL;
5468 switch ( _t.getType()) {
5474 _t = _t.getFirstChild();
5478 _t = _t.getNextSibling();
5486 _t = _t.getFirstChild();
5490 _t = _t.getNextSibling();
5498 _t = _t.getFirstChild();
5504 _t = _t.getNextSibling();
5512 _t = _t.getFirstChild();
5514 boolean synPredMatched260 =
false;
5515 if (_t==
null) _t=ASTNULL;
5516 if (((_t.getType()==
LPAREN))) {
5518 synPredMatched260 =
true;
5519 inputState.guessing++;
5524 _t = _t.getNextSibling();
5529 catch (RecognitionException pe) {
5530 synPredMatched260 =
false;
5533inputState.guessing--;
5535 if ( synPredMatched260 ) {
5538 _t = _t.getNextSibling();
5543 _t = _t.getNextSibling();
5550 throw new NoViableAltException(_t);
5555 _t = _t.getNextSibling();
5563 _t = _t.getFirstChild();
5565 boolean synPredMatched264 =
false;
5566 if (_t==
null) _t=ASTNULL;
5567 if (((_t.getType()==
LPAREN))) {
5569 synPredMatched264 =
true;
5570 inputState.guessing++;
5575 _t = _t.getNextSibling();
5580 catch (RecognitionException pe) {
5581 synPredMatched264 =
false;
5584inputState.guessing--;
5586 if ( synPredMatched264 ) {
5589 _t = _t.getNextSibling();
5594 _t = _t.getNextSibling();
5601 throw new NoViableAltException(_t);
5606 _t = _t.getNextSibling();
5611 throw new NoViableAltException(_t);
5615 catch (RecognitionException ex) {
5616 if (inputState.guessing==0) {
5618 if (_t!=
null) {_t = _t.getNextSibling();}
5628 TNode postfixExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5634 _t = _t.getFirstChild();
5641 if (_t==
null) _t=ASTNULL;
5642 switch ( _t.getType()) {
5647 _t = _t.getNextSibling();
5650 _t = _t.getNextSibling();
5657 _t = _t.getNextSibling();
5660 _t = _t.getNextSibling();
5668 _t = _t.getFirstChild();
5670 if (_t==
null) _t=ASTNULL;
5671 switch ( _t.getType()) {
5732 throw new NoViableAltException(_t);
5738 _t = _t.getNextSibling();
5740 _t = _t.getNextSibling();
5747 _t = _t.getNextSibling();
5752 _t = _t.getNextSibling();
5759 _t = _t.getNextSibling();
5766 _t = _t.getNextSibling();
5771 if ( _cnt271>=1 ) {
break _loop271; }
else {
throw new NoViableAltException(_t);}
5778 _t = _t.getNextSibling();
5780 catch (RecognitionException ex) {
5781 if (inputState.guessing==0) {
5783 if (_t!=
null) {_t = _t.getNextSibling();}
5793 TNode primaryExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5796 if (_t==
null) _t=ASTNULL;
5797 switch ( _t.getType()) {
5802 _t = _t.getNextSibling();
5809 _t = _t.getNextSibling();
5829 _t = _t.getFirstChild();
5833 _t = _t.getNextSibling();
5838 throw new NoViableAltException(_t);
5842 catch (RecognitionException ex) {
5843 if (inputState.guessing==0) {
5845 if (_t!=
null) {_t = _t.getNextSibling();}
5853 public final void commaExpr(AST _t)
throws RecognitionException {
5855 TNode commaExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5861 _t = _t.getFirstChild();
5867 _t = _t.getNextSibling();
5869 catch (RecognitionException ex) {
5870 if (inputState.guessing==0) {
5872 if (_t!=
null) {_t = _t.getNextSibling();}
5880 public final void emptyExpr(AST _t)
throws RecognitionException {
5882 TNode emptyExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5887 _t = _t.getNextSibling();
5889 catch (RecognitionException ex) {
5890 if (inputState.guessing==0) {
5892 if (_t!=
null) {_t = _t.getNextSibling();}
5902 TNode compoundStatementExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5908 _t = _t.getFirstChild();
5913 _t = _t.getNextSibling();
5915 _t = _t.getNextSibling();
5917 catch (RecognitionException ex) {
5918 if (inputState.guessing==0) {
5920 if (_t!=
null) {_t = _t.getNextSibling();}
5928 public final void rangeExpr(AST _t)
throws RecognitionException {
5930 TNode rangeExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5936 _t = _t.getFirstChild();
5941 _t = _t.getNextSibling();
5945 _t = _t.getNextSibling();
5947 catch (RecognitionException ex) {
5948 if (inputState.guessing==0) {
5950 if (_t!=
null) {_t = _t.getNextSibling();}
5958 public final void gnuAsmExpr(AST _t)
throws RecognitionException {
5960 TNode gnuAsmExpr_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
5966 _t = _t.getFirstChild();
5968 if (_t==
null) _t=ASTNULL;
5969 switch ( _t.getType()) {
5974 _t = _t.getNextSibling();
5983 throw new NoViableAltException(_t);
5989 _t = _t.getNextSibling();
5993 if (_t==
null) _t=ASTNULL;
5994 if ((_t.getType()==
COLON)) {
5997 _t = _t.getNextSibling();
5999 if (_t==
null) _t=ASTNULL;
6000 switch ( _t.getType()) {
6008 if (_t==
null) _t=ASTNULL;
6009 if ((_t.getType()==
COMMA)) {
6012 _t = _t.getNextSibling();
6031 throw new NoViableAltException(_t);
6036 if (_t==
null) _t=ASTNULL;
6037 if ((_t.getType()==
COLON)) {
6040 _t = _t.getNextSibling();
6042 if (_t==
null) _t=ASTNULL;
6043 switch ( _t.getType()) {
6051 if (_t==
null) _t=ASTNULL;
6052 if ((_t.getType()==
COMMA)) {
6055 _t = _t.getNextSibling();
6074 throw new NoViableAltException(_t);
6079 else if ((_t.getType()==
COLON||_t.getType()==
RPAREN)) {
6082 throw new NoViableAltException(_t);
6087 else if ((_t.getType()==
COLON||_t.getType()==
RPAREN)) {
6090 throw new NoViableAltException(_t);
6095 if (_t==
null) _t=ASTNULL;
6096 switch ( _t.getType()) {
6101 _t = _t.getNextSibling();
6107 if (_t==
null) _t=ASTNULL;
6108 if ((_t.getType()==
COMMA)) {
6111 _t = _t.getNextSibling();
6129 throw new NoViableAltException(_t);
6135 _t = _t.getNextSibling();
6137 _t = _t.getNextSibling();
6139 catch (RecognitionException ex) {
6140 if (inputState.guessing==0) {
6142 if (_t!=
null) {_t = _t.getNextSibling();}
6150 protected final void stringConst(AST _t)
throws RecognitionException {
6152 TNode stringConst_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
6158 _t = _t.getFirstChild();
6163 if (_t==
null) _t=ASTNULL;
6167 _t = _t.getNextSibling();
6170 if ( _cnt281>=1 ) {
break _loop281; }
else {
throw new NoViableAltException(_t);}
6177 _t = _t.getNextSibling();
6179 catch (RecognitionException ex) {
6180 if (inputState.guessing==0) {
6182 if (_t!=
null) {_t = _t.getNextSibling();}
6192 TNode strOptExprPair_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
6198 if (_t==
null) _t=ASTNULL;
6199 switch ( _t.getType()) {
6204 _t = _t.getNextSibling();
6209 _t = _t.getNextSibling();
6220 throw new NoViableAltException(_t);
6225 catch (RecognitionException ex) {
6226 if (inputState.guessing==0) {
6228 if (_t!=
null) {_t = _t.getNextSibling();}
6238 TNode unaryOperator_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
6241 if (_t==
null) _t=ASTNULL;
6242 switch ( _t.getType()) {
6247 _t = _t.getNextSibling();
6254 _t = _t.getNextSibling();
6261 _t = _t.getNextSibling();
6268 _t = _t.getNextSibling();
6275 _t = _t.getNextSibling();
6282 _t = _t.getNextSibling();
6289 _t = _t.getNextSibling();
6296 _t = _t.getNextSibling();
6303 _t = _t.getNextSibling();
6308 throw new NoViableAltException(_t);
6312 catch (RecognitionException ex) {
6313 if (inputState.guessing==0) {
6315 if (_t!=
null) {_t = _t.getNextSibling();}
6325 TNode argExprList_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
6332 if (_t==
null) _t=ASTNULL;
6338 if ( _cnt276>=1 ) {
break _loop276; }
else {
throw new NoViableAltException(_t);}
6345 catch (RecognitionException ex) {
6346 if (inputState.guessing==0) {
6348 if (_t!=
null) {_t = _t.getNextSibling();}
6356 protected final void charConst(AST _t)
throws RecognitionException {
6358 TNode charConst_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
6363 _t = _t.getNextSibling();
6365 catch (RecognitionException ex) {
6366 if (inputState.guessing==0) {
6368 if (_t!=
null) {_t = _t.getNextSibling();}
6376 protected final void intConst(AST _t)
throws RecognitionException {
6378 TNode intConst_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
6381 if (_t==
null) _t=ASTNULL;
6382 switch ( _t.getType()) {
6387 _t = _t.getNextSibling();
6394 _t = _t.getNextSibling();
6401 _t = _t.getNextSibling();
6408 _t = _t.getNextSibling();
6415 _t = _t.getNextSibling();
6422 _t = _t.getNextSibling();
6429 _t = _t.getNextSibling();
6436 _t = _t.getNextSibling();
6443 _t = _t.getNextSibling();
6448 throw new NoViableAltException(_t);
6452 catch (RecognitionException ex) {
6453 if (inputState.guessing==0) {
6455 if (_t!=
null) {_t = _t.getNextSibling();}
6463 protected final void floatConst(AST _t)
throws RecognitionException {
6465 TNode floatConst_AST_in = (_t == ASTNULL) ?
null : (
TNode)_t;
6468 if (_t==
null) _t=ASTNULL;
6469 switch ( _t.getType()) {
6474 _t = _t.getNextSibling();
6481 _t = _t.getNextSibling();
6488 _t = _t.getNextSibling();
6493 throw new NoViableAltException(_t);
6497 catch (RecognitionException ex) {
6498 if (inputState.guessing==0) {
6500 if (_t!=
null) {_t = _t.getNextSibling();}
6513 "NULL_TREE_LOOKAHEAD",
6613 "UnsignedOctalConst",
6621 "DoubleDoubleConst",
6626 "NStructDeclarator",
6631 "NFunctionCallArgs",
6632 "NNonemptyAbstractDeclarator",
6636 "NParameterTypeList",
6638 "NCompoundStatement",
6639 "NParameterDeclaration",
6646 "NInitializerElementLabel",
6647 "NLcurlyInitializer",
6679 private static final long[] mk_tokenSet_0() {
6680 long[] data = { 100794432L, 0L, 0L};
6684 private static final long[] mk_tokenSet_1() {
6685 long[] data = { 4398046387264L, 562949953421312L, 25769803776L, 0L, 0L, 0L};
6689 private static final long[] mk_tokenSet_2() {
6690 long[] data = { 544L, -9214364837600034816L, 4096L, 0L, 0L, 0L};
6694 private static final long[] mk_tokenSet_3() {
6695 long[] data = { -4616189618054757888L, 1152921504606846976L, 17L, 0L, 0L, 0L};
6699 private static final long[] mk_tokenSet_4() {
6700 long[] data = { 250688651132928L, 2972375790571749375L, 69793221356L, 0L, 0L, 0L};
A Number, either integer, optionally [long, unsigned], or floating point, optionally [double].
final boolean isInteger
true if number is integer and value stored in i, otherwise false for floating point and value stored ...
final boolean isUnsigned
true if number is an unsigned isInteger.
final long i
The value if isInteger.
final boolean isLong
true if number is a long isInteger.
Represents a [native] constant expression, comprises the [native] expression, see getNativeExpr() and...
CNumber getNumber()
Returns the parsed CNumber of the native expression, or null if the latter does not comprise a single...
A generic exception for Jogamp errors used throughout the binding as a substitute for RuntimeExceptio...
Parses and provides access to the contents of .cfg files for the JavaEmitter.
TypeInfo addTypeInfo(final String alias, final Type superType)
TypeInfo typeInfo(Type type)
If this type should be considered opaque, returns the TypeInfo describing the replacement type.
Class TNode is an implementation of the AST interface and adds many useful features:
String getAllChildrenText(final String name)
Returns the text for this node, its children and siblings.
String getText()
Get the token text for this node.
Represents an array type.
Models all compound types, i.e., those containing fields: structs and unions.
void setBodyParsed()
Indicates to this CompoundType that its body has been parsed and that no more addField operations wil...
static CompoundType create(final String structName, final SizeThunk size, final CompoundTypeKind kind, final int cvAttributes, final ASTLocusTag astLocus)
abstract boolean isUnion()
Indicates whether this type was declared as a union.
Represents a double-word floating-point type (C type "double".)
Describes enumerated types.
boolean removeEnumerate(final String name)
Remove the enumerate with the given name.
Enumerator getEnum(final int i)
Fetch ith (0..getNumEnumerates() - 1) Enumerator.
Represents a field in a struct or union.
Represents a single-word floating-point type (C type "float".)
Describes a function symbol, which includes the name and type.
void addArgument(final Type argumentType, final String argumentName)
Add an argument's name and type.
Describes a function type, used to model both function declarations and (via PointerType) function po...
void addArgument(final Type argumentType, final String argumentName)
Add an argument's name and type.
Provides a level of indirection between the definition of a type's size and the absolute value of thi...
static final SizeThunk INT8
static final SizeThunk DOUBLE
static final SizeThunk INT32
static SizeThunk constant(final int constant)
static SizeThunk mul(final SizeThunk thunk1, final SizeThunk thunk2)
static final SizeThunk POINTER
static final SizeThunk LONG
static final SizeThunk INT64
static final SizeThunk FLOAT
static final SizeThunk INT16
static final SizeThunk INTxx
Utility class for recording names of typedefs and structs.
Type get(final String name)
Get the type corresponding to the given name.
Type put(final String name, final Type type)
Create a mapping from a type to its name.
final String getCVAttributesString()
Returns a string indicating the const/volatile attributes of this type.
Type clone(final ASTLocusTag newLoc)
Clones this instance using a new ASTLocusTag.
final ASTLocusTag getASTLocusTag()
Returns this instance's ASTLocusTag, if available, otherwise returns null.
final boolean equalSemantics(final SemanticEqualityOp arg)
Semantic equality test for Types exclusive its given name.
final String getName()
Returns the name of this type.
boolean setTypedefName(final String name)
Set the typedef name of this type and renders this type a typedef, if given name has a length.
Type getTargetType()
Helper method to returns the target type of this type, in case another type is being referenced,...
final boolean isEnum()
Indicates whether this is an EnumType.
final Type newCVVariant(final int cvAttributes)
Return a variant of this type matching the given const/volatile attributes.
final String getDebugString()
final boolean isPointer()
Indicates whether this is a PointerType.
CompoundType asCompound()
Casts this to a CompoundType or returns null if not a CompoundType.
final boolean isCompound()
Indicates whether this is a CompoundType.
Type-safe enum for discriminating between structs and unions represented as compound types.
String getName()
Return the current-name, which is the last renamed-name if issued, or the original-name.
Enumeration for const/volatile attributes.
static final int VOLATILE