1 #include "Identifier.hpp"
  2 #include <soulng/util/Unicode.hpp>
  3 #include <sngcm/cmlexer/CmajorLexer.hpp>
  4 #include <sngcm/cmlexer/CmajorTokens.hpp>
  5 
  6 // this file has been automatically generated from 'C:/work/cmajorm/cmajor/sngcm/cmparser/Identifier.parser' using soulng parser generator spg version 3.10.0
  7 
  8 using namespace soulng::unicode;
  9 using namespace sngcm::ast;
 10 using namespace CmajorTokens;
 11 
 12 soulng::parser::Match IdentifierParser::Identifier(CmajorLexer& lexerboost::uuids::uuid* moduleId)
 13 {
 14     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
 15 
 16 
 17 
 18 
 19 
 20 
 21 
 22     #endif // SOULNG_PARSER_DEBUG_SUPPORT
 23     soulng::parser::Match match(false);
 24     soulng::parser::Match* parentMatch0 = &match;
 25     {
 26         int64_t pos = lexer.GetPos();
 27         soulng::lexer::Span span = lexer.GetSpan();
 28         soulng::parser::Match match(false);
 29         if (*lexer == ID)
 30         {
 31             ++lexer;
 32             match.hit = true;
 33         }
 34         if (match.hit)
 35         {
 36             {
 37                 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
 38 
 39                 #endif // SOULNG_PARSER_DEBUG_SUPPORT
 40                 return soulng::parser::Match(truenew IdentifierNode(span*moduleIdlexer.GetToken(pos)));
 41             }
 42         }
 43         *parentMatch0 = match;
 44     }
 45     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
 46 
 47 
 48 
 49 
 50 
 51     #endif // SOULNG_PARSER_DEBUG_SUPPORT
 52     if (!match.hit)
 53     {
 54         match.value = nullptr;
 55     }
 56     return match;
 57 }
 58 
 59 soulng::parser::Match IdentifierParser::QualifiedId(CmajorLexer& lexerboost::uuids::uuid* moduleId)
 60 {
 61     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
 62 
 63 
 64 
 65 
 66 
 67 
 68 
 69     #endif // SOULNG_PARSER_DEBUG_SUPPORT
 70     std::u32string value = std::u32string();
 71     Span s = Span();
 72     soulng::parser::Match match(false);
 73     soulng::parser::Match* parentMatch0 = &match;
 74     {
 75         int64_t pos = lexer.GetPos();
 76         soulng::parser::Match match(false);
 77         soulng::parser::Match* parentMatch1 = &match;
 78         {
 79             soulng::parser::Match match(false);
 80             soulng::parser::Match* parentMatch2 = &match;
 81             {
 82                 soulng::parser::Match match(false);
 83                 soulng::parser::Match* parentMatch3 = &match;
 84                 {
 85                     int64_t pos = lexer.GetPos();
 86                     soulng::lexer::Span span = lexer.GetSpan();
 87                     soulng::parser::Match match(false);
 88                     if (*lexer == ID)
 89                     {
 90                         ++lexer;
 91                         match.hit = true;
 92                     }
 93                     if (match.hit)
 94                     {
 95                         s = span;
 96                         Token token = lexer.GetToken(pos);
 97                         value.append(std::u32string(token.match.begintoken.match.end));
 98                     }
 99                     *parentMatch3 = match;
100                 }
101                 *parentMatch2 = match;
102             }
103             if (match.hit)
104             {
105                 soulng::parser::Match match(false);
106                 soulng::parser::Match* parentMatch4 = &match;
107                 {
108                     soulng::parser::Match match(true);
109                     soulng::parser::Match* parentMatch5 = &match;
110                     {
111                         while (true)
112                         {
113                             int64_t save = lexer.GetPos();
114                             {
115                                 soulng::parser::Match match(false);
116                                 soulng::parser::Match* parentMatch6 = &match;
117                                 {
118                                     soulng::parser::Match match(false);
119                                     soulng::parser::Match* parentMatch7 = &match;
120                                     {
121                                         soulng::parser::Match match(false);
122                                         if (*lexer == DOT)
123                                         {
124                                             ++lexer;
125                                             match.hit = true;
126                                         }
127                                         *parentMatch7 = match;
128                                     }
129                                     if (match.hit)
130                                     {
131                                         soulng::parser::Match match(false);
132                                         soulng::parser::Match* parentMatch8 = &match;
133                                         {
134                                             soulng::parser::Match match(false);
135                                             soulng::parser::Match* parentMatch9 = &match;
136                                             {
137                                                 int64_t pos = lexer.GetPos();
138                                                 soulng::lexer::Span span = lexer.GetSpan();
139                                                 soulng::parser::Match match(false);
140                                                 if (*lexer == ID)
141                                                 {
142                                                     ++lexer;
143                                                     match.hit = true;
144                                                 }
145                                                 if (match.hit)
146                                                 {
147                                                     s.end = span.end;
148                                                     Token token = lexer.GetToken(pos);
149                                                     value.append(1'.');
150                                                     value.append(std::u32string(token.match.begintoken.match.end));
151                                                 }
152                                                 *parentMatch9 = match;
153                                             }
154                                             *parentMatch8 = match;
155                                         }
156                                         *parentMatch7 = match;
157                                     }
158                                     *parentMatch6 = match;
159                                 }
160                                 if (match.hit)
161                                 {
162                                     *parentMatch5 = match;
163                                 }
164                                 else
165                                 {
166                                     lexer.SetPos(save);
167                                     break;
168                                 }
169                             }
170                         }
171                     }
172                     *parentMatch4 = match;
173                 }
174                 *parentMatch2 = match;
175             }
176             *parentMatch1 = match;
177         }
178         if (match.hit)
179         {
180             {
181                 #ifdef SOULNG_PARSER_DEBUG_SUPPORT
182 
183                 #endif // SOULNG_PARSER_DEBUG_SUPPORT
184                 return soulng::parser::Match(truenew IdentifierNode(s*moduleIdvalue));
185             }
186         }
187         *parentMatch0 = match;
188     }
189     #ifdef SOULNG_PARSER_DEBUG_SUPPORT
190 
191 
192 
193 
194 
195     #endif // SOULNG_PARSER_DEBUG_SUPPORT
196     if (!match.hit)
197     {
198         match.value = nullptr;
199     }
200     return match;
201 }