3 public class ASTPointer : ASTNode
11 if(qualifiers) qualifiers.print();
12 if(pointer) pointer.print();
19 while(peekToken().type == '*')
22 ptr = { pointer = ptr };
28 public class ASTDeclarator : ASTNode
34 ASTDeclarator ::parse()
36 ASTDeclarator decl = null;
38 if(peekToken().type == '*')
39 decl = DeclPointer::parse();
42 if(peekToken().type == IDENTIFIER)
43 decl = DeclIdentifier::parse();
44 else if(nextToken.type == '(')
45 decl = DeclBrackets::parse();
50 if(peekToken().type == '[')
51 decl = DeclArray::parse(decl);
52 else if(nextToken.type == '(')
53 decl = DeclFunction::parse(decl);
63 public class TypeNameList : ASTList<ASTTypeName>
65 TypeNameList ::parse()
67 TypeNameList list = null;
68 int a = pushAmbiguity();
71 ASTTypeName e = ASTTypeName::parse();
73 if(e && (nextToken.type == ',' || nextToken.type == ')'))
79 if(nextToken.type == ',')
96 // return (TypeNameList)ASTList::parse(class(TypeNameList), ASTTypeName::parse, ',');
100 public class DeclFunction : ASTDeclarator
103 ASTDeclarator declarator;
104 TypeNameList parameters;
108 if(declarator) declarator.print();
110 if(parameters) parameters.print();
114 DeclFunction ::parse(ASTDeclarator d)
116 DeclFunction decl { declarator = d };
118 if(peekToken().type != ')') decl.parameters = TypeNameList::parse();
119 if(peekToken().type == ')')
125 public class DeclIdentifier : ASTDeclarator
127 ASTIdentifier identifier;
131 if(identifier) identifier.print();
134 DeclIdentifier ::parse()
136 return { identifier = ASTIdentifier::parse() };
140 public class DeclBrackets : ASTDeclarator
142 ASTDeclarator declarator;
147 if(declarator) declarator.print();
151 DeclBrackets ::parse()
153 DeclBrackets decl = null;
156 d = ASTDeclarator::parse();
158 decl = { declarator = d };
159 if(peekToken().type == ')')
165 public class DeclArray : ASTDeclarator
167 ASTDeclarator declarator;
169 // ASTSpecifier enumClass;
173 if(declarator) declarator.print();
179 DeclArray ::parse(ASTDeclarator d)
181 DeclArray decl { declarator = d };
183 if(peekToken().type != ']') decl.exp = ExpConditional::parse();
184 if(peekToken().type == ']') readToken();
189 public class DeclPointer : ASTDeclarator
191 ASTDeclarator declarator;
196 if(pointer) pointer.print();
197 if(declarator) declarator.print();
200 DeclPointer ::parse()
202 return { pointer = ASTPointer::parse(), declarator = ASTDeclarator::parse() };
206 public class DeclStruct : ASTDeclarator
208 ASTDeclarator declarator;
210 ASTExpression posExp;
215 return { declarator = ASTDeclarator::parse(); };
219 public class DeclExtended : ASTDeclarator
224 public class ASTInitializer : ASTNode
227 ASTInitializer ::parse()
229 if(peekToken().type == '{')
233 init = InitList::parse();
234 if(peekToken().type == '}') readToken();
238 return InitExp { exp = ASTExpression::parse() };
242 public class InitExp : ASTInitializer
253 public class InitList : ASTInitializer
255 ASTList<ASTInitializer> list;
269 ASTList<ASTInitializer> list = (ASTList<ASTInitializer>)ASTList::parse(class(ASTList<ASTInitializer>), ASTInitializer::parse, ',');
270 return list ? { list = (void *)list } : null;
274 public class ASTInitDeclarator : ASTNode
276 ASTDeclarator declarator;
277 ASTInitializer initializer;
281 if(declarator) declarator.print();
289 ASTInitDeclarator ::parse()
291 ASTDeclarator decl = ASTDeclarator::parse();
294 ASTInitializer init = null;
295 if(peekToken().type == '=')
298 init = ASTInitializer::parse();
300 return { declarator = decl, initializer = init };
306 public class InitDeclList : ASTList<ASTInitDeclarator>
308 InitDeclList ::parse()
310 return (InitDeclList)ASTList::parse(class(InitDeclList), ASTInitDeclarator::parse, ',');