Allow implicit cast from null to maybe types ("Type?")
[delight/core.git] / dmd2 / parse.h
blobe79f5da4677803411c9fecb280869feba2016170
2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2007 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 TypeQualified;
24 struct Expression;
25 struct Declaration;
26 struct Statement;
27 struct Import;
28 struct Initializer;
29 struct FuncDeclaration;
30 struct CtorDeclaration;
31 struct PostBlitDeclaration;
32 struct DtorDeclaration;
33 struct StaticCtorDeclaration;
34 struct StaticDtorDeclaration;
35 struct ConditionalDeclaration;
36 struct InvariantDeclaration;
37 struct UnitTestDeclaration;
38 struct NewDeclaration;
39 struct DeleteDeclaration;
40 struct Condition;
41 struct Module;
42 struct ModuleDeclaration;
43 struct TemplateDeclaration;
44 struct TemplateInstance;
45 struct StaticAssert;
47 /************************************
48 * These control how parseStatement() works.
51 enum ParseStatementFlags
53 PSsemi = 1, // empty ';' statements are allowed
54 PSscope = 2, // start a new scope
55 PScurly = 4, // { } statement is required
56 PScurlyscope = 8, // { } starts a new scope
60 struct Parser : Lexer
62 ModuleDeclaration *md;
63 enum LINK linkage;
64 Loc endloc; // set to location of last right curly
65 int inBrackets; // inside [] of array index or slice
67 Parser(Module *module, unsigned char *base, unsigned length, int doDocComment);
69 Array *parseModule();
70 Array *parseDeclDefs(int once);
71 Array *parseBlock();
72 TemplateDeclaration *parseTemplateDeclaration();
73 TemplateParameters *parseTemplateParameterList(int flag = 0);
74 Dsymbol *parseMixin();
75 Objects *parseTemplateArgumentList();
76 Objects *parseTemplateArgumentList2();
77 StaticAssert *parseStaticAssert();
78 TypeQualified *parseTypeof();
79 enum LINK parseLinkage();
80 Condition *parseDebugCondition();
81 Condition *parseVersionCondition();
82 Condition *parseStaticIfCondition();
83 FuncDeclaration *parseCtor();
84 PostBlitDeclaration *parsePostBlit();
85 DtorDeclaration *parseDtor();
86 StaticCtorDeclaration *parseStaticCtor();
87 StaticDtorDeclaration *parseStaticDtor();
88 InvariantDeclaration *parseInvariant();
89 UnitTestDeclaration *parseUnitTest();
90 NewDeclaration *parseNew();
91 DeleteDeclaration *parseDelete();
92 Arguments *parseParameters(int *pvarargs);
93 EnumDeclaration *parseEnum();
94 Dsymbol *parseAggregate();
95 BaseClasses *parseBaseClasses();
96 Import *parseImport(Array *decldefs, int isstatic);
97 Type *parseType(Identifier **pident = NULL, TemplateParameters **tpl = NULL);
98 Type *parseBasicType();
99 Type *parseBasicType2(Type *t);
100 Type *parseDeclarator(Type *t, Identifier **pident, TemplateParameters **tpl = NULL);
101 Array *parseDeclarations();
102 void parseContracts(FuncDeclaration *f);
103 Statement *parseStatement(int flags);
104 Statement *parseExtAsm(int expect_rparen);
105 Initializer *parseInitializer();
106 Expression *parseDefaultInitExp();
107 void check(Loc loc, enum TOK value);
108 void check(enum TOK value);
109 void check(enum TOK value, char *string);
110 int isDeclaration(Token *t, int needId, enum TOK endtok, Token **pt);
111 int isBasicType(Token **pt);
112 int isDeclarator(Token **pt, int *haveId, enum TOK endtok);
113 int isParameters(Token **pt);
114 int isExpression(Token **pt);
115 int isTemplateInstance(Token *t, Token **pt);
116 int skipParens(Token *t, Token **pt);
118 Expression *parseExpression();
119 Expression *parsePrimaryExp();
120 Expression *parseUnaryExp();
121 Expression *parsePostExp(Expression *e);
122 Expression *parseMulExp();
123 Expression *parseAddExp();
124 Expression *parseShiftExp();
125 Expression *parseRelExp();
126 Expression *parseEqualExp();
127 Expression *parseCmpExp();
128 Expression *parseAndExp();
129 Expression *parseXorExp();
130 Expression *parseOrExp();
131 Expression *parseAndAndExp();
132 Expression *parseOrOrExp();
133 Expression *parseCondExp();
134 Expression *parseAssignExp();
136 Expressions *parseArguments();
138 Expression *parseNewExp(Expression *thisexp);
140 void addComment(Dsymbol *s, unsigned char *blockComment);
143 #endif /* DMD_PARSE_H */