1
|
1
|
|
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.
|
|
10
|
|
11 #ifndef DMD_PARSE_H
|
|
12 #define DMD_PARSE_H
|
|
13
|
|
14 #ifdef __DMC__
|
|
15 #pragma once
|
|
16 #endif /* __DMC__ */
|
|
17
|
|
18 #include "arraytypes.h"
|
|
19 #include "lexer.h"
|
|
20 #include "enum.h"
|
|
21
|
|
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;
|
|
44
|
|
45 /************************************
|
|
46 * These control how parseStatement() works.
|
|
47 */
|
|
48
|
|
49 enum ParseStatementFlags
|
|
50 {
|
|
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 };
|
|
56
|
|
57
|
|
58 struct Parser : Lexer
|
|
59 {
|
|
60 ModuleDeclaration *md;
|
|
61 enum LINK linkage;
|
|
62 Loc endloc; // set to location of last right curly
|
|
63 int inBrackets; // inside [] of array index or slice
|
|
64
|
|
65 Parser(Module *module, unsigned char *base, unsigned length, int doDocComment);
|
|
66
|
|
67 Array *parseModule();
|
|
68 Array *parseDeclDefs(int once);
|
|
69 Array *parseBlock();
|
|
70 TemplateDeclaration *parseTemplateDeclaration();
|
|
71 TemplateParameters *parseTemplateParameterList();
|
|
72 Dsymbol *parseMixin();
|
|
73 Objects *parseTemplateArgumentList();
|
|
74 StaticAssert *parseStaticAssert();
|
|
75 enum LINK parseLinkage();
|
|
76 Condition *parseDebugCondition();
|
|
77 Condition *parseVersionCondition();
|
|
78 Condition *parseStaticIfCondition();
|
|
79 CtorDeclaration *parseCtor();
|
|
80 DtorDeclaration *parseDtor();
|
|
81 StaticCtorDeclaration *parseStaticCtor();
|
|
82 StaticDtorDeclaration *parseStaticDtor();
|
|
83 InvariantDeclaration *parseInvariant();
|
|
84 UnitTestDeclaration *parseUnitTest();
|
|
85 NewDeclaration *parseNew();
|
|
86 DeleteDeclaration *parseDelete();
|
|
87 Arguments *parseParameters(int *pvarargs);
|
|
88 EnumDeclaration *parseEnum();
|
|
89 Dsymbol *parseAggregate();
|
|
90 BaseClasses *parseBaseClasses();
|
|
91 Import *parseImport(Array *decldefs, int isstatic);
|
|
92 Type *parseBasicType();
|
|
93 Type *parseBasicType2(Type *t);
|
|
94 Type *parseDeclarator(Type *t, Identifier **pident, TemplateParameters **tpl = NULL);
|
|
95 Array *parseDeclarations();
|
|
96 void parseContracts(FuncDeclaration *f);
|
|
97 Statement *parseStatement(int flags);
|
|
98 Initializer *parseInitializer();
|
|
99 void check(Loc loc, enum TOK value);
|
|
100 void check(enum TOK value);
|
|
101 void check(enum TOK value, char *string);
|
|
102 int isDeclaration(Token *t, int needId, enum TOK endtok, Token **pt);
|
|
103 int isBasicType(Token **pt);
|
|
104 int isDeclarator(Token **pt, int *haveId, enum TOK endtok);
|
|
105 int isParameters(Token **pt);
|
|
106 int isExpression(Token **pt);
|
|
107 int isTemplateInstance(Token *t, Token **pt);
|
|
108 int skipParens(Token *t, Token **pt);
|
|
109
|
|
110 Expression *parseExpression();
|
|
111 Expression *parsePrimaryExp();
|
|
112 Expression *parseUnaryExp();
|
|
113 Expression *parsePostExp(Expression *e);
|
|
114 Expression *parseMulExp();
|
|
115 Expression *parseAddExp();
|
|
116 Expression *parseShiftExp();
|
|
117 Expression *parseRelExp();
|
|
118 Expression *parseEqualExp();
|
|
119 Expression *parseCmpExp();
|
|
120 Expression *parseAndExp();
|
|
121 Expression *parseXorExp();
|
|
122 Expression *parseOrExp();
|
|
123 Expression *parseAndAndExp();
|
|
124 Expression *parseOrOrExp();
|
|
125 Expression *parseCondExp();
|
|
126 Expression *parseAssignExp();
|
|
127
|
|
128 Expressions *parseArguments();
|
|
129
|
|
130 Expression *parseNewExp(Expression *thisexp);
|
|
131
|
|
132 void addComment(Dsymbol *s, unsigned char *blockComment);
|
|
133 };
|
|
134
|
|
135 #endif /* DMD_PARSE_H */
|