Allow log_ statements outside of a class
[delight/core.git] / dmd / parse.h
blob46c99caf1f3cd5ea310264d9abe9eaa34972aad7
2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2006 by Digital Mars
4 // All Rights Reserved
5 // written by Walter Bright
6 // http://www.digitalmars.com
7 // License for redistribution is by either the Artistic License
8 // in artistic.txt, or the GNU General Public License in gnu.txt.
9 // See the included readme.txt for details.
11 #ifndef DMD_PARSE_H
12 #define DMD_PARSE_H
14 #ifdef __DMC__
15 #pragma once
16 #endif /* __DMC__ */
18 #include "arraytypes.h"
19 #include "lexer.h"
20 #include "enum.h"
22 struct Type;
23 struct Expression;
24 struct Declaration;
25 struct Statement;
26 struct Import;
27 struct Initializer;
28 struct FuncDeclaration;
29 struct CtorDeclaration;
30 struct DtorDeclaration;
31 struct StaticCtorDeclaration;
32 struct StaticDtorDeclaration;
33 struct ConditionalDeclaration;
34 struct InvariantDeclaration;
35 struct UnitTestDeclaration;
36 struct NewDeclaration;
37 struct DeleteDeclaration;
38 struct Condition;
39 struct Module;
40 struct ModuleDeclaration;
41 struct TemplateDeclaration;
42 struct TemplateInstance;
43 struct StaticAssert;
45 /************************************
46 * These control how parseStatement() works.
49 enum ParseStatementFlags
51 PSsemi = 1, // empty ';' statements are allowed
52 PSscope = 2, // start a new scope
53 PScurly = 4, // { } statement is required
54 PScurlyscope = 8, // { } starts a new scope
55 PScolon = 16, // in Delight, : is required
59 struct Parser : Lexer
61 ModuleDeclaration *md;
62 enum LINK linkage;
63 Loc endloc; // set to location of last right curly
64 int inBrackets; // inside [] of array index or slice
65 TOK startBlockTok;
67 Parser(Module *module, unsigned char *base, unsigned length, int doDocComment);
69 Array *parseModule();
70 Array *parseDeclDefs(int once);
71 virtual Array *parseBlock();
72 TemplateDeclaration *parseTemplateDeclaration();
73 TemplateParameters *parseTemplateParameterList();
74 Dsymbol *parseMixin();
75 Objects *parseTemplateArgumentList();
76 StaticAssert *parseStaticAssert();
77 enum LINK parseLinkage();
78 Condition *parseDebugCondition();
79 Condition *parseVersionCondition();
80 Condition *parseStaticIfCondition();
81 CtorDeclaration *parseCtor();
82 DtorDeclaration *parseDtor();
83 StaticCtorDeclaration *parseStaticCtor();
84 StaticDtorDeclaration *parseStaticDtor();
85 InvariantDeclaration *parseInvariant();
86 UnitTestDeclaration *parseUnitTest();
87 NewDeclaration *parseNew();
88 DeleteDeclaration *parseDelete();
89 Arguments *parseParameters(int *pvarargs);
90 EnumDeclaration *parseEnum();
91 Dsymbol *parseAggregate();
92 BaseClasses *parseBaseClasses();
93 Import *parseImport(Array *decldefs, int isstatic);
94 Type *parseBasicType();
95 Type *parseBasicType2(Type *t);
96 Type *parseDeclarator(Type *t, Identifier **pident, TemplateParameters **tpl = NULL);
97 Array *parseDeclarations();
98 void parseContracts(FuncDeclaration *f);
99 virtual Statement *parseStatement(int flags);
100 Statement *parseExtAsm(int expect_rparen);
101 Initializer *parseInitializer();
102 void optionalEndline();
103 void check(Loc loc, enum TOK value);
104 void check(enum TOK value);
105 void check(enum TOK value, char *string);
106 virtual void checkLParen();
107 virtual void checkRParen();
108 virtual char *endToken(); // for error messages
109 int isDeclaration(Token *t, int needId, enum TOK endtok, Token **pt);
110 int isBasicType(Token **pt);
111 int isDeclarator(Token **pt, int *haveId, enum TOK endtok);
112 int isParameters(Token **pt);
113 int isExpression(Token **pt);
114 int isTemplateInstance(Token *t, Token **pt);
115 int skipParens(Token *t, Token **pt);
117 Expression *parseExpression();
118 Expression *parsePrimaryExp();
119 Expression *parseUnaryExp();
120 Expression *parsePostExp(Expression *e);
121 Expression *parseMulExp();
122 Expression *parseAddExp();
123 Expression *parseShiftExp();
124 Expression *parseRelExp();
125 Expression *parseEqualExp();
126 Expression *parseCmpExp();
127 Expression *parseAndExp();
128 Expression *parseXorExp();
129 Expression *parseOrExp();
130 Expression *parseAndAndExp();
131 Expression *parseOrOrExp();
132 virtual Expression *parseCondExp();
133 Expression *parseAssignExp();
135 Expressions *parseArguments();
137 Expression *parseNewExp(Expression *thisexp);
138 Statement *logStatement(int level);
140 void addComment(Dsymbol *s, unsigned char *blockComment);
143 /************************************
144 * Delight
147 struct DltParser : Parser {
148 DltParser(Module *module, unsigned char *base, unsigned length, int doDocComment);
150 Statement *parseStatement(int flags);
151 Array *parseBlock();
152 Expression *parseCondExp();
153 char *endToken();
154 void checkLParen();
155 void checkRParen();
158 #endif /* DMD_PARSE_H */