annotate trunk/src/dil/parser/ImportParser.d @ 682:7541c64fc423

Renamed FunctionBody, CatchBody and FinallyBody. FunctionBody -> FuncBodyStatement, CatchBody -> CatchStatement, FinallyBody -> FinallyStatement.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 19 Jan 2008 20:35:45 +0100
parents 6b3e397229c5
children b11d46260909
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 +/
579
90d0cff4107e Moved ImportParser.d to package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 578
diff changeset
5 module dil.parser.ImportParser;
578
c769bc239006 Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 495
diff changeset
6
596
39fac5531b85 Moved dil.Token to dil.lexer.Token.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 587
diff changeset
7 import dil.parser.Parser;
580
fa6d3c52757d Moved SyntaxTree.d to new package 'ast'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 579
diff changeset
8 import dil.ast.Node;
585
05c375fb2d5c Moved dil.Declarations to dil.ast.Declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 580
diff changeset
9 import dil.ast.Declarations;
587
7d0ba0c93e95 Moved dil.Statements to dil.ast.Statements.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 585
diff changeset
10 import dil.ast.Statements;
596
39fac5531b85 Moved dil.Token to dil.lexer.Token.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 587
diff changeset
11 import dil.Enums;
492
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
680
6b3e397229c5 Renamed Statements, Declarations and EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 679
diff changeset
23 override CompoundDeclaration start()
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
24 {
680
6b3e397229c5 Renamed Statements, Declarations and EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 679
diff changeset
25 auto decls = new CompoundDeclaration;
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
26 super.init();
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
27 if (token.kind == T.Module)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
28 decls ~= parseModuleDeclaration();
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
29 while (token.kind != T.EOF)
492
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);
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
37 while (token.kind != T.RBrace && token.kind != T.EOF)
492
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 {
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
44 switch (token.kind)
492
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();
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
51 while (token.kind != T.RBrace && token.kind != T.EOF)
492
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 {
619
933cd8d24467 Renamed Parser.lx to Parser.lexer.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
65 lexer.peek(next);
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
66 if (next.kind == opening)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
67 ++level;
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
68 else if (next.kind == closing && --level == 0)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
69 return true;
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
70 else if (next.kind == T.EOF)
492
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 {
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
90 token.kind == tok && nT();
492
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;
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
96 switch (token.kind)
492
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 {
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
117 switch (token.kind)
492
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();
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
121 if (token.kind == T.LParen)
492
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();
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
140 token.kind == T.LParen && skipToTokenAfterClosingParen();
492
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);
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
184 if (token.kind == T.Else)
492
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();
495
b60450804b6e Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 492
diff changeset
199 decl.setProtection(prot); // Set the protection attribute.
673
64fec49651cf Renamed VariableDeclaration to VariablesDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 633
diff changeset
200 imports ~= decl.to!(ImportDeclaration);
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
201 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
202 case T.Enum:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
203 nT();
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
204 token.kind == T.Identifier && nT();
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
205 if (token.kind == T.Colon)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
206 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
207 nT();
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
208 while (token.kind != T.LBrace && token.kind != T.EOF)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
209 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
210 }
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
211 if (token.kind == T.Semicolon)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
212 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
213 else
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
214 skipToTokenAfterClosingBrace();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
215 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
216 case T.Class:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
217 case T.Interface:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
218 nT(), skip(T.Identifier); // class Identifier
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
219 token.kind == T.LParen && skipToTokenAfterClosingParen(); // Skip template params.
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
220 if (token.kind == T.Colon)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
221 { // BaseClasses
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
222 nT();
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
223 while (token.kind != T.LBrace && token.kind != T.EOF)
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
224 if (token.kind == T.LParen) // Skip ( tokens... )
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
225 skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
226 else
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
227 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
228 }
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
229 if (token.kind == T.Semicolon)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
230 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
231 else
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
232 parseDeclarationDefinitionsBlock(Protection.None);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
233 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
234 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
235 nT(); skip(T.Identifier);
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
236 token.kind == T.LParen && skipToTokenAfterClosingParen();
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
237 if (token.kind == T.Semicolon)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
238 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
239 else
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
240 parseDeclarationDefinitionsBlock(Protection.None);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
241 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
242 case T.Tilde:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
243 nT(); // ~
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
244 case T.This:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
245 nT(); nT(); nT(); // this ( )
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
246 parseFunctionBody();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
247 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
248 case T.Invariant:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
249 version(D2)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
250 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
251 auto next = token;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
252 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
253 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
254 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
255 goto case_Declaration;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
256 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
257 else
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
258 goto case_InvariantAttribute;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
259 }
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
260 token.kind == T.LParen && skipToTokenAfterClosingParen();
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
261 parseFunctionBody();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
262 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
263 case T.Unittest:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
264 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
265 parseFunctionBody();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
266 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
267 case T.Debug:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
268 nT();
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
269 if (token.kind == T.Assign)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
270 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
271 nT(), nT(), nT(); // = Condition ;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
272 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
273 }
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
274 if (token.kind == T.LParen)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
275 nT(), nT(), nT(); // ( Condition )
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
276 parseDeclarationsBlock(prot);
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
277 if (token.kind == T.Else)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
278 nT(), parseDeclarationsBlock(prot);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
279 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
280 case T.Version:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
281 nT();
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
282 if (token.kind == T.Assign)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
283 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
284 nT(), nT(), nT(); // = Condition ;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
285 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
286 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
287 nT(), nT(), nT(); // ( Condition )
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
288 parseDeclarationsBlock(prot);
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
289 if (token.kind == T.Else)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
290 nT(), parseDeclarationsBlock(prot);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
291 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
292 case T.Template:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
293 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
294 skip(T.Identifier);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
295 skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
296 parseDeclarationDefinitionsBlock(Protection.None);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
297 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
298 case T.New:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
299 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
300 skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
301 parseFunctionBody();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
302 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
303 case T.Delete:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
304 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
305 skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
306 parseFunctionBody();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
307 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
308 case T.Mixin:
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
309 while (token.kind != T.Semicolon && token.kind != T.EOF)
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
310 if (token.kind == T.LParen)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
311 skipToTokenAfterClosingParen();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
312 else
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
313 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
314 skip(T.Semicolon);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
315 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
316 case T.Semicolon:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
317 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
318 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
319 // Declaration
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
320 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
321 case_Declaration:
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
322 while (token.kind != T.Semicolon && token.kind != T.EOF)
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
323 if (token.kind == T.LParen)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
324 skipToTokenAfterClosingParen();
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
325 else if (token.kind == T.LBrace)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
326 skipToTokenAfterClosingBrace();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
327 else
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
328 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
329 skip(T.Semicolon);
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
330 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
331 default:
633
5fa1886d6aaf Replaced a case statement with an if statement in ImportParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 619
diff changeset
332 if (token.isIntegralType)
5fa1886d6aaf Replaced a case statement with an if statement in ImportParser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 619
diff changeset
333 goto case_Declaration;
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
334 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
335 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
336 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
337
682
7541c64fc423 Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 680
diff changeset
338 FuncBodyStatement parseFunctionBody()
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
339 {
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
340 while (1)
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
341 {
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
342 switch (token.kind)
492
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 case T.LBrace:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
345 skipToTokenAfterClosingBrace();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
346 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
347 case T.Semicolon:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
348 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
349 break;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
350 case T.In:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
351 nT();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
352 skipToTokenAfterClosingBrace();
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
353 continue;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
354 case T.Out:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
355 nT();
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 673
diff changeset
356 if (token.kind == T.LParen)
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
357 nT(), nT(), nT(); // ( Identifier )
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.Body:
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 goto case T.LBrace;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
363 default:
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
364 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
365 break; // Exit loop.
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
366 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
367 return null;
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
368 }
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
369 }