1 
  2 // this file has been automatically generated from 'D:/work/cmajorm/cmajor/build/BuildLang.lexer' using soulng lexer generator slg version 3.0.0
  3 
  4 #include <cmajor/build/BuildLangLexer.hpp>
  5 #include <cmajor/build/BuildLangKeywords.hpp>
  6 #include <soulng/lexer/Token.hpp>
  7 #include <cmajor/build/BuildLangTokens.hpp>
  8 #include <cmajor/build/BuildLangClassMap.hpp>
  9 
 10 using namespace soulng::lexer;
 11 using namespace BuildLangTokens;
 12 
 13 BuildLangLexer::BuildLangLexer(const std::u32string& content_const std::string& fileName_int fileIndex_) : soulng::lexer::Lexer(content_fileName_fileIndex_)
 14 {
 15     SetKeywordMap(BuildLangKeywords::GetKeywordMap());
 16 }
 17 
 18 BuildLangLexer::BuildLangLexer(const char32_t* start_const char32_t* end_const std::string& fileName_int fileIndex_) : soulng::lexer::Lexer(start_end_fileName_fileIndex_)
 19 {
 20     SetKeywordMap(BuildLangKeywords::GetKeywordMap());
 21 }
 22 
 23 int BuildLangLexer::NextState(int statechar32_t c)
 24 {
 25     int i = BuildLangClassMap::GetClass(c);
 26     switch (state)
 27     {
 28         case 0:
 29         {
 30             switch (i)
 31             {
 32                 case 0:
 33                 {
 34                     return 1;
 35                 }
 36                 case 2:
 37                 case 3:
 38                 {
 39                     return 2;
 40                 }
 41                 case 4:
 42                 {
 43                     return 3;
 44                 }
 45                 case 5:
 46                 {
 47                     return 4;
 48                 }
 49                 case 6:
 50                 {
 51                     return 5;
 52                 }
 53                 case 7:
 54                 {
 55                     return 6;
 56                 }
 57                 case 10:
 58                 {
 59                     return 7;
 60                 }
 61                 case 11:
 62                 {
 63                     return 8;
 64                 }
 65                 case 12:
 66                 {
 67                     return 9;
 68                 }
 69                 case 13:
 70                 {
 71                     return 10;
 72                 }
 73                 default:
 74                 {
 75                     return -1;
 76                 }
 77             }
 78         }
 79         case 10:
 80         {
 81             Lexeme prevMatch = token.match;
 82             token.match = lexeme;
 83             int tokenId = GetTokenId(8);
 84             if (tokenId == CONTINUE_TOKEN)
 85             {
 86                 token.id = tokenId;
 87                 return -1;
 88             }
 89             else if (tokenId != INVALID_TOKEN)
 90             {
 91                 token.id = tokenId;
 92             }
 93             else
 94             {
 95                 token.match = prevMatch;
 96             }
 97             return -1;
 98         }
 99         case 9:
100         {
101             Lexeme prevMatch = token.match;
102             token.match = lexeme;
103             int tokenId = GetTokenId(7);
104             if (tokenId == CONTINUE_TOKEN)
105             {
106                 token.id = tokenId;
107                 return -1;
108             }
109             else if (tokenId != INVALID_TOKEN)
110             {
111                 token.id = tokenId;
112             }
113             else
114             {
115                 token.match = prevMatch;
116             }
117             return -1;
118         }
119         case 8:
120         {
121             Lexeme prevMatch = token.match;
122             token.match = lexeme;
123             int tokenId = GetTokenId(6);
124             if (tokenId == CONTINUE_TOKEN)
125             {
126                 token.id = tokenId;
127                 return -1;
128             }
129             else if (tokenId != INVALID_TOKEN)
130             {
131                 token.id = tokenId;
132             }
133             else
134             {
135                 token.match = prevMatch;
136             }
137             return -1;
138         }
139         case 7:
140         {
141             Lexeme prevMatch = token.match;
142             token.match = lexeme;
143             int tokenId = GetTokenId(5);
144             if (tokenId == CONTINUE_TOKEN)
145             {
146                 token.id = tokenId;
147                 return -1;
148             }
149             else if (tokenId != INVALID_TOKEN)
150             {
151                 token.id = tokenId;
152             }
153             else
154             {
155                 token.match = prevMatch;
156             }
157             return -1;
158         }
159         case 6:
160         {
161             switch (i)
162             {
163                 case 0:
164                 case 1:
165                 case 2:
166                 case 3:
167                 case 4:
168                 case 5:
169                 case 6:
170                 case 7:
171                 case 8:
172                 case 10:
173                 case 11:
174                 case 12:
175                 case 13:
176                 {
177                     return 11;
178                 }
179                 case 9:
180                 {
181                     return 12;
182                 }
183                 default:
184                 {
185                     return -1;
186                 }
187             }
188         }
189         case 12:
190         {
191             Lexeme prevMatch = token.match;
192             token.match = lexeme;
193             int tokenId = GetTokenId(4);
194             if (tokenId == CONTINUE_TOKEN)
195             {
196                 token.id = tokenId;
197                 return -1;
198             }
199             else if (tokenId != INVALID_TOKEN)
200             {
201                 token.id = tokenId;
202             }
203             else
204             {
205                 token.match = prevMatch;
206             }
207             return -1;
208         }
209         case 11:
210         {
211             switch (i)
212             {
213                 case 0:
214                 case 1:
215                 case 2:
216                 case 3:
217                 case 4:
218                 case 5:
219                 case 6:
220                 case 7:
221                 case 8:
222                 case 10:
223                 case 11:
224                 case 12:
225                 case 13:
226                 {
227                     return 11;
228                 }
229                 case 9:
230                 {
231                     return 12;
232                 }
233                 default:
234                 {
235                     return -1;
236                 }
237             }
238         }
239         case 5:
240         {
241             Lexeme prevMatch = token.match;
242             token.match = lexeme;
243             int tokenId = GetTokenId(3);
244             if (tokenId == CONTINUE_TOKEN)
245             {
246                 token.id = tokenId;
247                 return -1;
248             }
249             else if (tokenId != INVALID_TOKEN)
250             {
251                 token.id = tokenId;
252             }
253             else
254             {
255                 token.match = prevMatch;
256             }
257             switch (i)
258             {
259                 case 6:
260                 {
261                     return 5;
262                 }
263                 default:
264                 {
265                     return -1;
266                 }
267             }
268         }
269         case 4:
270         {
271             Lexeme prevMatch = token.match;
272             token.match = lexeme;
273             int tokenId = GetTokenId(1);
274             if (tokenId == CONTINUE_TOKEN)
275             {
276                 token.id = tokenId;
277                 return -1;
278             }
279             else if (tokenId != INVALID_TOKEN)
280             {
281                 token.id = tokenId;
282             }
283             else
284             {
285                 token.match = prevMatch;
286             }
287             return -1;
288         }
289         case 3:
290         {
291             Lexeme prevMatch = token.match;
292             token.match = lexeme;
293             int tokenId = GetTokenId(1);
294             if (tokenId == CONTINUE_TOKEN)
295             {
296                 token.id = tokenId;
297                 return -1;
298             }
299             else if (tokenId != INVALID_TOKEN)
300             {
301                 token.id = tokenId;
302             }
303             else
304             {
305                 token.match = prevMatch;
306             }
307             switch (i)
308             {
309                 case 5:
310                 {
311                     return 13;
312                 }
313                 default:
314                 {
315                     return -1;
316                 }
317             }
318         }
319         case 13:
320         {
321             Lexeme prevMatch = token.match;
322             token.match = lexeme;
323             int tokenId = GetTokenId(1);
324             if (tokenId == CONTINUE_TOKEN)
325             {
326                 token.id = tokenId;
327                 return -1;
328             }
329             else if (tokenId != INVALID_TOKEN)
330             {
331                 token.id = tokenId;
332             }
333             else
334             {
335                 token.match = prevMatch;
336             }
337             return -1;
338         }
339         case 2:
340         {
341             Lexeme prevMatch = token.match;
342             token.match = lexeme;
343             int tokenId = GetTokenId(0);
344             if (tokenId == CONTINUE_TOKEN)
345             {
346                 token.id = tokenId;
347                 return -1;
348             }
349             else if (tokenId != INVALID_TOKEN)
350             {
351                 token.id = tokenId;
352             }
353             else
354             {
355                 token.match = prevMatch;
356             }
357             switch (i)
358             {
359                 case 2:
360                 case 3:
361                 {
362                     return 2;
363                 }
364                 default:
365                 {
366                     return -1;
367                 }
368             }
369         }
370         case 1:
371         {
372             Lexeme prevMatch = token.match;
373             token.match = lexeme;
374             int tokenId = GetTokenId(2);
375             if (tokenId == CONTINUE_TOKEN)
376             {
377                 token.id = tokenId;
378                 return -1;
379             }
380             else if (tokenId != INVALID_TOKEN)
381             {
382                 token.id = tokenId;
383             }
384             else
385             {
386                 token.match = prevMatch;
387             }
388             switch (i)
389             {
390                 case 0:
391                 case 1:
392                 case 6:
393                 {
394                     return 14;
395                 }
396                 default:
397                 {
398                     return -1;
399                 }
400             }
401         }
402         case 14:
403         {
404             Lexeme prevMatch = token.match;
405             token.match = lexeme;
406             int tokenId = GetTokenId(2);
407             if (tokenId == CONTINUE_TOKEN)
408             {
409                 token.id = tokenId;
410                 return -1;
411             }
412             else if (tokenId != INVALID_TOKEN)
413             {
414                 token.id = tokenId;
415             }
416             else
417             {
418                 token.match = prevMatch;
419             }
420             switch (i)
421             {
422                 case 0:
423                 case 1:
424                 case 6:
425                 {
426                     return 14;
427                 }
428                 default:
429                 {
430                     return -1;
431                 }
432             }
433         }
434     }
435     return -1;
436 }
437 
438 int BuildLangLexer::GetTokenId(int statementIndex)
439 {
440     switch (statementIndex)
441     {
442         case 0:
443         {
444             Retract();
445             break;
446         }
447         case 1:
448         {
449             Retract();
450             break;
451         }
452         case 2:
453         {
454             Retract();
455             int kw = GetKeywordToken(token.match);
456             if (kw == INVALID_TOKEN) return ID;
457             else return kw;
458             break;
459         }
460         case 3:
461         {
462             Retract();
463             return INTEGER;
464             break;
465         }
466         case 4:
467         {
468             Retract();
469             return FILEPATH;
470             break;
471         }
472         case 5:
473         {
474             Retract();
475             return LBRACKET;
476             break;
477         }
478         case 6:
479         {
480             Retract();
481             return RBRACKET;
482             break;
483         }
484         case 7:
485         {
486             Retract();
487             return EQ;
488             break;
489         }
490         case 8:
491         {
492             Retract();
493             return DOT;
494             break;
495         }
496     }
497     return CONTINUE_TOKEN;
498 }