3 public class ASTDeclaration : ASTStmtOrDecl
8 ASTDeclaration ::parse(SpecsList specs, InitDeclList decls)
10 if(peekToken().type == ';')
12 return DeclarationInit { specifiers = specs, declarators = decls };
16 public class DeclarationInit : ASTDeclaration
20 InitDeclList declarators;
36 public class ASTFunctionDefinition : ASTNode
40 ASTDeclarator declarator;
41 List<ASTDeclaration> oldStyleDeclarations;
60 ASTFunctionDefinition ::parse(SpecsList specs, InitDeclList decls)
62 ASTFunctionDefinition function { };
63 ASTDeclarator decl = (decls && decls[0]) ? decls[0].declarator : null;
64 if(decl && decls[0]) decls[0].declarator = null;
66 function.specifiers = (void *)specs; // TOFIX: #768
67 function.declarator = decl;
68 function.body = StmtCompound::parse();
73 OldList attached; // For IDE
80 bool propertyNoThis; // Not used yet; might use to support both this = and return syntax for conversion properties
87 FunctionDefinition function;
88 ClassDefinition _class;
89 Declaration declaration;
94 ImportType importType;
98 public class AST : ASTList<ASTNode>
100 ASTNode ::ParseExternalDeclaration()
102 SpecsList specs = SpecsList::parse();
103 InitDeclList decls = InitDeclList::parse();
105 if(peekToken().type == '{')
106 return ASTFunctionDefinition::parse(specs, decls);
107 else if(specs || decls)
108 return ASTDeclaration::parse(specs, decls);
111 readToken(); // Error
119 while(peekToken().type)
121 ASTNode n = ParseExternalDeclaration();