Added Delight "normal" mode restrictions
[delight/core.git] / dmd / parse.h
blob0bbaab4aa369fd064600fec288e5310f97b8588a
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;
66 bool dltNormalMode; // disallow various dangerous features
68 Parser(Module *module, unsigned char *base, unsigned length, int doDocComment);
70 Array *parseModule();
71 Array *parseDeclDefs(int once);
72 virtual Array *parseBlock();
73 TemplateDeclaration *parseTemplateDeclaration();
74 TemplateParameters *parseTemplateParameterList();
75 Dsymbol *parseMixin();
76 Objects *parseTemplateArgumentList();
77 StaticAssert *parseStaticAssert();
78 enum LINK parseLinkage();
79 Condition *parseDebugCondition();
80 Condition *parseVersionCondition();
81 Condition *parseStaticIfCondition();
82 CtorDeclaration *parseCtor();
83 DtorDeclaration *parseDtor();
84 StaticCtorDeclaration *parseStaticCtor();
85 StaticDtorDeclaration *parseStaticDtor();
86 InvariantDeclaration *parseInvariant();
87 UnitTestDeclaration *parseUnitTest();
88 NewDeclaration *parseNew();
89 DeleteDeclaration *parseDelete();
90 Arguments *parseParameters(int *pvarargs);
91 EnumDeclaration *parseEnum();
92 Dsymbol *parseAggregate();
93 BaseClasses *parseBaseClasses();
94 Import *parseImport(Array *decldefs, int isstatic);
95 Type *parseBasicType();
96 Type *parseBasicType2(Type *t);
97 Type *parseDeclarator(Type *t, Identifier **pident, TemplateParameters **tpl = NULL);
98 Array *parseDeclarations();
99 void parseContracts(FuncDeclaration *f);
100 virtual Statement *parseStatement(int flags);
101 Statement *parseExtAsm(int expect_rparen);
102 Initializer *parseInitializer();
103 void optionalEndline();
104 void check(Loc loc, enum TOK value);
105 void check(enum TOK value);
106 void check(enum TOK value, char *string);
107 virtual void checkLParen();
108 virtual void checkRParen();
109 virtual char *endToken(); // for error messages
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 virtual Expression *parseCondExp();
134 Expression *parseAssignExp();
136 Expressions *parseArguments();
138 Expression *parseNewExp(Expression *thisexp);
139 Statement *logStatement(int level);
141 void addComment(Dsymbol *s, unsigned char *blockComment);
144 /************************************
145 * Delight
148 struct DltParser : Parser {
149 DltParser(Module *module, unsigned char *base, unsigned length, int doDocComment);
151 Statement *parseStatement(int flags);
152 Array *parseBlock();
153 Expression *parseCondExp();
154 char *endToken();
155 void checkLParen();
156 void checkRParen();
159 #endif /* DMD_PARSE_H */