root/trunk/src/parse.h

Revision 886, 5.3 kB (checked in by walter, 1 year ago)

bugzilla 2581 DDoc doesn't work for functions with auto return type.

  • Property svn:eol-style set to native
Line 
1 // Compiler implementation of the D programming language
2 // Copyright (c) 1999-2009 by Digital Mars
3 // All Rights Reserved
4 // written by Walter Bright
5 // http://www.digitalmars.com
6 // License for redistribution is by either the Artistic License
7 // in artistic.txt, or the GNU General Public License in gnu.txt.
8 // See the included readme.txt for details.
9
10 #ifndef DMD_PARSE_H
11 #define DMD_PARSE_H
12
13 #ifdef __DMC__
14 #pragma once
15 #endif /* __DMC__ */
16
17 #include "arraytypes.h"
18 #include "lexer.h"
19 #include "enum.h"
20
21 struct Type;
22 struct TypeQualified;
23 struct Expression;
24 struct Declaration;
25 struct Statement;
26 struct Import;
27 struct Initializer;
28 struct FuncDeclaration;
29 struct CtorDeclaration;
30 struct PostBlitDeclaration;
31 struct DtorDeclaration;
32 struct StaticCtorDeclaration;
33 struct StaticDtorDeclaration;
34 struct SharedStaticCtorDeclaration;
35 struct SharedStaticDtorDeclaration;
36 struct ConditionalDeclaration;
37 struct InvariantDeclaration;
38 struct UnitTestDeclaration;
39 struct NewDeclaration;
40 struct DeleteDeclaration;
41 struct Condition;
42 struct Module;
43 struct ModuleDeclaration;
44 struct TemplateDeclaration;
45 struct TemplateInstance;
46 struct StaticAssert;
47
48 /************************************
49  * These control how parseStatement() works.
50  */
51
52 enum ParseStatementFlags
53 {
54     PSsemi = 1,         // empty ';' statements are allowed
55     PSscope = 2,        // start a new scope
56     PScurly = 4,        // { } statement is required
57     PScurlyscope = 8,   // { } starts a new scope
58 };
59
60
61 struct Parser : Lexer
62 {
63     ModuleDeclaration *md;
64     enum LINK linkage;
65     Loc endloc;                 // set to location of last right curly
66     int inBrackets;             // inside [] of array index or slice
67
68     Parser(Module *module, unsigned char *base, unsigned length, int doDocComment);
69
70     Dsymbols *parseModule();
71     Dsymbols *parseDeclDefs(int once);
72     Dsymbols *parseAutoDeclarations(StorageClass storageClass, unsigned char *comment);
73     Dsymbols *parseBlock();
74     void composeStorageClass(StorageClass stc);
75     StorageClass parseAttribute();
76     StorageClass parsePostfix();
77     Expression *parseConstraint();
78     TemplateDeclaration *parseTemplateDeclaration(int ismixin);
79     TemplateParameters *parseTemplateParameterList(int flag = 0);
80     Dsymbol *parseMixin();
81     Objects *parseTemplateArgumentList();
82     Objects *parseTemplateArgumentList2();
83     Objects *parseTemplateArgument();
84     StaticAssert *parseStaticAssert();
85     TypeQualified *parseTypeof();
86     enum LINK parseLinkage();
87     Condition *parseDebugCondition();
88     Condition *parseVersionCondition();
89     Condition *parseStaticIfCondition();
90     Dsymbol *parseCtor();
91     PostBlitDeclaration *parsePostBlit();
92     DtorDeclaration *parseDtor();
93     StaticCtorDeclaration *parseStaticCtor();
94     StaticDtorDeclaration *parseStaticDtor();
95     SharedStaticCtorDeclaration *parseSharedStaticCtor();
96     SharedStaticDtorDeclaration *parseSharedStaticDtor();
97     InvariantDeclaration *parseInvariant();
98     UnitTestDeclaration *parseUnitTest();
99     NewDeclaration *parseNew();
100     DeleteDeclaration *parseDelete();
101     Parameters *parseParameters(int *pvarargs);
102     EnumDeclaration *parseEnum();
103     Dsymbol *parseAggregate();
104     BaseClasses *parseBaseClasses();
105     Import *parseImport(Dsymbols *decldefs, int isstatic);
106     Type *parseType(Identifier **pident = NULL, TemplateParameters **tpl = NULL);
107     Type *parseBasicType();
108     Type *parseBasicType2(Type *t);
109     Type *parseDeclarator(Type *t, Identifier **pident, TemplateParameters **tpl = NULL);
110     Dsymbols *parseDeclarations(StorageClass storage_class, unsigned char *comment);
111     void parseContracts(FuncDeclaration *f);
112     Statement *parseStatement(int flags);
113     Initializer *parseInitializer();
114     Expression *parseDefaultInitExp();
115     void check(Loc loc, enum TOK value);
116     void check(enum TOK value);
117     void check(enum TOK value, const char *string);
118     void checkParens(enum TOK value, Expression *e);
119     int isDeclaration(Token *t, int needId, enum TOK endtok, Token **pt);
120     int isBasicType(Token **pt);
121     int isDeclarator(Token **pt, int *haveId, enum TOK endtok);
122     int isParameters(Token **pt);
123     int isExpression(Token **pt);
124     int isTemplateInstance(Token *t, Token **pt);
125     int skipParens(Token *t, Token **pt);
126
127     Expression *parseExpression();
128     Expression *parsePrimaryExp();
129     Expression *parseUnaryExp();
130     Expression *parsePostExp(Expression *e);
131     Expression *parseMulExp();
132     Expression *parseAddExp();
133     Expression *parseShiftExp();
134 #if DMDV1
135     Expression *parseRelExp();
136     Expression *parseEqualExp();
137 #endif
138     Expression *parseCmpExp();
139     Expression *parseAndExp();
140     Expression *parseXorExp();
141     Expression *parseOrExp();
142     Expression *parseAndAndExp();
143     Expression *parseOrOrExp();
144     Expression *parseCondExp();
145     Expression *parseAssignExp();
146
147     Expressions *parseArguments();
148
149     Expression *parseNewExp(Expression *thisexp);
150
151     void addComment(Dsymbol *s, unsigned char *blockComment);
152 };
153
154 // Operator precedence - greater values are higher precedence
155
156 enum PREC
157 {
158     PREC_zero,
159     PREC_expr,
160     PREC_assign,
161     PREC_cond,
162     PREC_oror,
163     PREC_andand,
164     PREC_or,
165     PREC_xor,
166     PREC_and,
167     PREC_equal,
168     PREC_rel,
169     PREC_shift,
170     PREC_add,
171     PREC_mul,
172     PREC_pow,
173     PREC_unary,
174     PREC_primary,
175 };
176
177 extern enum PREC precedence[TOKMAX];
178
179 void initPrecedence();
180
181 #endif /* DMD_PARSE_H */
Note: See TracBrowser for help on using the browser.