1 using System;
2 using System.Collections;
3 using System.Lex;
4 using System.Parsing;
5 using Cm.Ast;
6 using ParserFileTokens;
7
8
9
10 public static class ParIdentifierParser
11 {
12 public static Match Identifier(ParserFileLexer& lexer, ParsingContext* ctx)
13 {
14 #if (DEBUG)
15 Span debugSpan;
16 bool writeToLog = lexer.Log() != null;
17 if (writeToLog)
18 {
19 debugSpan = lexer.GetSpan();
20 System.Lex.WriteBeginRuleToLog(lexer, u"Identifier");
21 }
22 #endif
23 Match match(false);
24 Match* parentMatch0 = &match;
25 {
26 long pos = lexer.GetPos();
27 Span span = lexer.GetSpan();
28 Match match(false);
29 if (*lexer == ID)
30 {
31 ++lexer;
32 match.hit = true;
33 }
34 if (match.hit)
35 {
36 {
37 #if (DEBUG)
38 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Identifier");
39 #endif
40 return Match(true, new IdentifierNode(span, ctx->ModuleId(), lexer.GetToken(pos)));
41 }
42 }
43 *parentMatch0 = match;
44 }
45 #if (DEBUG)
46 if (writeToLog)
47 {
48 if (match.hit)
49 {
50 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"Identifier");
51 }
52 else
53 {
54 System.Lex.WriteFailureToLog(lexer, u"Identifier");
55 }
56 }
57 #endif
58 if (!match.hit)
59 {
60 match.value = null;
61 }
62 return match;
63 }
64 public static Match QualifiedId(ParserFileLexer& lexer, ParsingContext* ctx)
65 {
66 #if (DEBUG)
67 Span debugSpan;
68 bool writeToLog = lexer.Log() != null;
69 if (writeToLog)
70 {
71 debugSpan = lexer.GetSpan();
72 System.Lex.WriteBeginRuleToLog(lexer, u"QualifiedId");
73 }
74 #endif
75 ustring value;
76 Span s;
77 Match match(false);
78 Match* parentMatch0 = &match;
79 {
80 long pos = lexer.GetPos();
81 Match match(false);
82 Match* parentMatch1 = &match;
83 {
84 Match match(false);
85 Match* parentMatch2 = &match;
86 {
87 Match match(false);
88 Match* parentMatch3 = &match;
89 {
90 long pos = lexer.GetPos();
91 Span span = lexer.GetSpan();
92 Match match(false);
93 if (*lexer == ID)
94 {
95 ++lexer;
96 match.hit = true;
97 }
98 if (match.hit)
99 {
100 s = span;
101 Token token = lexer.GetToken(pos);
102 value.Append(ustring(token.match.begin, token.match.end));
103 }
104 *parentMatch3 = match;
105 }
106 *parentMatch2 = match;
107 }
108 if (match.hit)
109 {
110 Match match(false);
111 Match* parentMatch4 = &match;
112 {
113 Match match(true);
114 Match* parentMatch5 = &match;
115 {
116 while (true)
117 {
118 long save = lexer.GetPos();
119 {
120 Match match(false);
121 Match* parentMatch6 = &match;
122 {
123 Match match(false);
124 Match* parentMatch7 = &match;
125 {
126 Match match(false);
127 if (*lexer == DOT)
128 {
129 ++lexer;
130 match.hit = true;
131 }
132 *parentMatch7 = match;
133 }
134 if (match.hit)
135 {
136 Match match(false);
137 Match* parentMatch8 = &match;
138 {
139 Match match(false);
140 Match* parentMatch9 = &match;
141 {
142 long pos = lexer.GetPos();
143 Span span = lexer.GetSpan();
144 Match match(false);
145 if (*lexer == ID)
146 {
147 ++lexer;
148 match.hit = true;
149 }
150 if (match.hit)
151 {
152 s.end = span.end;
153 Token token = lexer.GetToken(pos);
154 value.Append('.');
155 value.Append(ustring(token.match.begin, token.match.end));
156 }
157 *parentMatch9 = match;
158 }
159 *parentMatch8 = match;
160 }
161 *parentMatch7 = match;
162 }
163 *parentMatch6 = match;
164 }
165 if (match.hit)
166 {
167 *parentMatch5 = match;
168 }
169 else
170 {
171 lexer.SetPos(save);
172 break;
173 }
174 }
175 }
176 }
177 *parentMatch4 = match;
178 }
179 *parentMatch2 = match;
180 }
181 *parentMatch1 = match;
182 }
183 if (match.hit)
184 {
185 {
186 #if (DEBUG)
187 if (writeToLog) System.Lex.WriteSuccessToLog(lexer, debugSpan, u"QualifiedId");
188 #endif
189 return Match(true, new IdentifierNode(s, ctx->ModuleId(), value));
190 }
191 }
192 *parentMatch0 = match;
193 }
194 #if (DEBUG)
195 if (writeToLog)
196 {
197 if (match.hit)
198 {
199 System.Lex.WriteSuccessToLog(lexer, debugSpan, u"QualifiedId");
200 }
201 else
202 {
203 System.Lex.WriteFailureToLog(lexer, u"QualifiedId");
204 }
205 }
206 #endif
207 if (!match.hit)
208 {
209 match.value = null;
210 }
211 return match;
212 }
213 }