Detect when the input ends in .dlt and use DltParser
[delight/core.git] / dmd / parse.h
blobe1a647112bcaed0c9ddabb7591a439adcf49fa81
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
58 struct Parser : Lexer
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
65 Parser(Module *module, unsigned char *base, unsigned length, int doDocComment);
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 Statement *parseExtAsm(int expect_rparen);
99 Initializer *parseInitializer();
100 void check(Loc loc, enum TOK value);
101 void check(enum TOK value);
102 void check(enum TOK value, char *string);
103 int isDeclaration(Token *t, int needId, enum TOK endtok, Token **pt);
104 int isBasicType(Token **pt);
105 int isDeclarator(Token **pt, int *haveId, enum TOK endtok);
106 int isParameters(Token **pt);
107 int isExpression(Token **pt);
108 int isTemplateInstance(Token *t, Token **pt);
109 int skipParens(Token *t, Token **pt);
111 Expression *parseExpression();
112 Expression *parsePrimaryExp();
113 Expression *parseUnaryExp();
114 Expression *parsePostExp(Expression *e);
115 Expression *parseMulExp();
116 Expression *parseAddExp();
117 Expression *parseShiftExp();
118 Expression *parseRelExp();
119 Expression *parseEqualExp();
120 Expression *parseCmpExp();
121 Expression *parseAndExp();
122 Expression *parseXorExp();
123 Expression *parseOrExp();
124 Expression *parseAndAndExp();
125 Expression *parseOrOrExp();
126 Expression *parseCondExp();
127 Expression *parseAssignExp();
129 Expressions *parseArguments();
131 Expression *parseNewExp(Expression *thisexp);
133 void addComment(Dsymbol *s, unsigned char *blockComment);
136 /************************************
137 * Delight
140 struct DltParser : Parser {
141 DltParser(Module *module, unsigned char *base, unsigned length, int doDocComment);
144 #endif /* DMD_PARSE_H */