annotate trunk/src/dil/ImportParser.d @ 492:9c208925a3d4

Added module ImportParser and new stuff from DMD2.008. Moved ImportParser from module Parser to its own module. Added a few methods from class Parser and simplified them. Now protection attributes are taken into consideration as well. Added class TemplateThisParameter. Adapted TypeofType so that typeof(return) can be recognized.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Thu, 06 Dec 2007 22:19:55 +0100
parents
children b60450804b6e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
1 /++
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
2 Author: Aziz Köksal
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
3 License: GPL3
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
4 +/
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
5 module dil.ImportParser;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
6 import dil.Parser;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
7 import dil.Token;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
8 import dil.Enums;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
9 import dil.Declarations;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
10 import dil.Statements;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
11 import dil.SyntaxTree;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
12 import common;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
13
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
14 private alias TOK T;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
15
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
16 class ImportParser : Parser
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
17 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
18 this(char[] srcText, string fileName)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
19 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
20 super(srcText, fileName);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
21 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
22
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
23 override Declarations start()
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
24 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
25 auto decls = new Declarations;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
26 super.init();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
27 if (token.type == T.Module)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
28 decls ~= parseModuleDeclaration();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
29 while (token.type != T.EOF)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
30 parseDeclarationDefinition(Protection.None);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
31 return decls;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
32 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
33
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
34 void parseDeclarationDefinitionsBlock(Protection prot)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
35 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
36 skip(T.LBrace);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
37 while (token.type != T.RBrace && token.type != T.EOF)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
38 parseDeclarationDefinition(prot);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
39 skip(T.RBrace);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
40 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
41
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
42 void parseDeclarationsBlock(Protection prot)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
43 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
44 switch (token.type)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
45 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
46 case T.LBrace:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
47 parseDeclarationDefinitionsBlock(prot);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
48 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
49 case T.Colon:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
50 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
51 while (token.type != T.RBrace && token.type != T.EOF)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
52 parseDeclarationDefinition(prot);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
53 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
54 default:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
55 parseDeclarationDefinition(prot);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
56 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
57 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
58
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
59 bool skipToClosing(T opening, T closing)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
60 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
61 Token* next = token;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
62 uint level = 1;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
63 while (1)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
64 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
65 lx.peek(next);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
66 if (next.type == opening)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
67 ++level;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
68 else if (next.type == closing && --level == 0)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
69 return true;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
70 else if (next.type == T.EOF)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
71 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
72 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
73 return false;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
74 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
75
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
76 void skipToTokenAfterClosingParen()
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
77 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
78 skipToClosing(T.LParen, T.RParen);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
79 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
80 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
81
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
82 void skipToTokenAfterClosingBrace()
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
83 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
84 skipToClosing(T.LBrace, T.RBrace);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
85 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
86 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
87
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
88 void skip(TOK tok)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
89 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
90 token.type == tok && nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
91 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
92
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
93 void parseProtectionAttribute()
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
94 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
95 Protection prot;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
96 switch (token.type)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
97 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
98 case T.Private:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
99 prot = Protection.Private; break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
100 case T.Package:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
101 prot = Protection.Package; break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
102 case T.Protected:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
103 prot = Protection.Protected; break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
104 case T.Public:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
105 prot = Protection.Public; break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
106 case T.Export:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
107 prot = Protection.Export; break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
108 default:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
109 assert(0);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
110 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
111 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
112 parseDeclarationsBlock(prot);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
113 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
114
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
115 void parseDeclarationDefinition(Protection prot)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
116 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
117 switch (token.type)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
118 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
119 case T.Align:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
120 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
121 if (token.type == T.LParen)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
122 nT(), nT(), nT(); // ( Integer )
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
123 parseDeclarationsBlock(prot);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
124 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
125 case T.Pragma:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
126 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
127 skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
128 parseDeclarationsBlock(prot);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
129 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
130 case T.Export,
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
131 T.Private,
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
132 T.Package,
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
133 T.Protected,
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
134 T.Public:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
135 parseProtectionAttribute();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
136 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
137 // Storage classes
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
138 case T.Extern:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
139 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
140 token.type == T.LParen && skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
141 parseDeclarationsBlock(prot);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
142 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
143 case T.Const:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
144 version(D2)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
145 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
146 if (peekNext() == T.LParen)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
147 goto case_Declaration;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
148 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
149 case T.Override,
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
150 T.Deprecated,
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
151 T.Abstract,
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
152 T.Synchronized,
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
153 // T.Static,
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
154 T.Final,
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
155 T.Auto,
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
156 T.Scope:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
157 case_StaticAttribute:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
158 case_InvariantAttribute:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
159 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
160 parseDeclarationsBlock(prot);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
161 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
162 // End of storage classes.
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
163 case T.Alias, T.Typedef:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
164 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
165 goto case_Declaration;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
166 case T.Static:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
167 switch (peekNext())
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
168 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
169 case T.Import:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
170 goto case_Import;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
171 case T.This:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
172 nT(), nT(); // static this
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
173 skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
174 parseFunctionBody();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
175 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
176 case T.Tilde:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
177 nT(), nT(), nT(), nT(), nT(); // static ~ this ( )
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
178 parseFunctionBody();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
179 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
180 case T.If:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
181 nT(), nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
182 skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
183 parseDeclarationsBlock(prot);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
184 if (token.type == T.Else)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
185 nT(), parseDeclarationsBlock(prot);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
186 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
187 case T.Assert:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
188 nT(), nT(); // static assert
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
189 skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
190 skip(T.Semicolon);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
191 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
192 default:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
193 goto case_StaticAttribute;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
194 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
195 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
196 case T.Import:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
197 case_Import:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
198 auto decl = parseImportDeclaration();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
199 assert(decl && decl.kind == NodeKind.ImportDeclaration);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
200 decl.prot = prot; // Set the protection attribute.
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
201 imports ~= cast(ImportDeclaration)cast(void*)decl;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
202 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
203 case T.Enum:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
204 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
205 token.type == T.Identifier && nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
206 if (token.type == T.Colon)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
207 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
208 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
209 while (token.type != T.LBrace && token.type != T.EOF)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
210 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
211 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
212 if (token.type == T.Semicolon)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
213 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
214 else
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
215 skipToTokenAfterClosingBrace();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
216 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
217 case T.Class:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
218 case T.Interface:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
219 nT(), skip(T.Identifier); // class Identifier
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
220 token.type == T.LParen && skipToTokenAfterClosingParen(); // Skip template params.
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
221 if (token.type == T.Colon)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
222 { // BaseClasses
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
223 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
224 while (token.type != T.LBrace && token.type != T.EOF)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
225 if (token.type == T.LParen) // Skip ( tokens... )
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
226 skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
227 else
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
228 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
229 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
230 if (token.type == T.Semicolon)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
231 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
232 else
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
233 parseDeclarationDefinitionsBlock(Protection.None);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
234 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
235 case T.Struct, T.Union:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
236 nT(); skip(T.Identifier);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
237 token.type == T.LParen && skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
238 if (token.type == T.Semicolon)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
239 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
240 else
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
241 parseDeclarationDefinitionsBlock(Protection.None);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
242 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
243 case T.Tilde:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
244 nT(); // ~
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
245 case T.This:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
246 nT(); nT(); nT(); // this ( )
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
247 parseFunctionBody();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
248 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
249 case T.Invariant:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
250 version(D2)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
251 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
252 auto next = token;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
253 if (peekAfter(next) == T.LParen)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
254 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
255 if (peekAfter(next) != T.RParen)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
256 goto case_Declaration;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
257 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
258 else
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
259 goto case_InvariantAttribute;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
260 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
261 token.type == T.LParen && skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
262 parseFunctionBody();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
263 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
264 case T.Unittest:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
265 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
266 parseFunctionBody();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
267 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
268 case T.Debug:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
269 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
270 if (token.type == T.Assign)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
271 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
272 nT(), nT(), nT(); // = Condition ;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
273 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
274 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
275 if (token.type == T.LParen)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
276 nT(), nT(), nT(); // ( Condition )
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
277 parseDeclarationsBlock(prot);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
278 if (token.type == T.Else)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
279 nT(), parseDeclarationsBlock(prot);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
280 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
281 case T.Version:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
282 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
283 if (token.type == T.Assign)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
284 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
285 nT(), nT(), nT(); // = Condition ;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
286 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
287 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
288 nT(), nT(), nT(); // ( Condition )
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
289 parseDeclarationsBlock(prot);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
290 if (token.type == T.Else)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
291 nT(), parseDeclarationsBlock(prot);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
292 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
293 case T.Template:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
294 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
295 skip(T.Identifier);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
296 skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
297 parseDeclarationDefinitionsBlock(Protection.None);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
298 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
299 case T.New:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
300 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
301 skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
302 parseFunctionBody();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
303 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
304 case T.Delete:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
305 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
306 skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
307 parseFunctionBody();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
308 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
309 case T.Mixin:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
310 while (token.type != T.Semicolon && token.type != T.EOF)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
311 if (token.type == T.LParen)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
312 skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
313 else
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
314 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
315 skip(T.Semicolon);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
316 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
317 case T.Semicolon:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
318 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
319 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
320 // Declaration
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
321 case T.Identifier, T.Dot, T.Typeof:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
322 // IntegralType
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
323 case T.Char, T.Wchar, T.Dchar, T.Bool,
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
324 T.Byte, T.Ubyte, T.Short, T.Ushort,
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
325 T.Int, T.Uint, T.Long, T.Ulong,
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
326 T.Float, T.Double, T.Real,
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
327 T.Ifloat, T.Idouble, T.Ireal,
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
328 T.Cfloat, T.Cdouble, T.Creal, T.Void:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
329 case_Declaration:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
330 while (token.type != T.Semicolon && token.type != T.EOF)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
331 if (token.type == T.LParen)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
332 skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
333 else if (token.type == T.LBrace)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
334 skipToTokenAfterClosingBrace();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
335 else
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
336 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
337 skip(T.Semicolon);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
338 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
339 default:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
340 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
341 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
342 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
343
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
344 FunctionBody parseFunctionBody()
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
345 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
346 while (1)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
347 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
348 switch (token.type)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
349 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
350 case T.LBrace:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
351 skipToTokenAfterClosingBrace();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
352 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
353 case T.Semicolon:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
354 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
355 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
356 case T.In:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
357 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
358 skipToTokenAfterClosingBrace();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
359 continue;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
360 case T.Out:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
361 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
362 if (token.type == T.LParen)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
363 nT(), nT(), nT(); // ( Identifier )
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
364 skipToTokenAfterClosingBrace();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
365 continue;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
366 case T.Body:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
367 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
368 goto case T.LBrace;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
369 default:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
370 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
371 break; // Exit loop.
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
372 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
373 return null;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
374 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
375 }