1 // =================================
  2 // Copyright (c) 2020 Seppo Laakko
  3 // Distributed under the MIT license
  4 // =================================
  5 
  6 #include <sngcpp/symbols/SymbolCreator.hpp>
  7 #include <sngcpp/symbols/SymbolTable.hpp>
  8 #include <sngcpp/symbols/TemplateSymbol.hpp>
  9 #include <sngcpp/symbols/ParameterSymbol.hpp>
 10 #include <sngcpp/ast/SourceFile.hpp>
 11 #include <sngcpp/ast/Expression.hpp>
 12 #include <sngcpp/ast/Template.hpp>
 13 #include <sngcpp/ast/Enumeration.hpp>
 14 #include <sngcpp/ast/TypeExpr.hpp>
 15 
 16 namespace sngcpp { namespace symbols {
 17 
 18 SymbolCreator::SymbolCreator(SymbolTable& symbolTable_const std::u32string& projectName_) :
 19     symbolTable(symbolTable_)projectName(projectName_)functionBodyFollowsOrIsPureDeletedOrDefault(false)nameSequenceCount(0)wasFunctionDeclaration(false)wasArrayDeclaration(false)
 20     specifiers(Specifier::none)skip(false)processingTemplateArguments(false)cpp2cmMode(false)
 21 {
 22 }
 23 
 24 void SymbolCreator::Visit(SourceFileNode& sourceFileNode)
 25 {
 26     sourceFileNode.GlobalNs()->Accept(*this);
 27 }
 28 
 29 void SymbolCreator::Visit(SourceFileSequenceNode& sourceFileSequenceNode)
 30 {
 31     sourceFileSequenceNode.Left()->Accept(*this);
 32     sourceFileSequenceNode.Right()->Accept(*this);
 33 }
 34 
 35 void SymbolCreator::Visit(NamespaceNode& namespaceNode)
 36 {
 37     symbolTable.BeginNamespace(namespaceNode.NamespaceName()projectName);
 38     if (namespaceNode.Child())
 39     {
 40         namespaceNode.Child()->Accept(*this);
 41     }
 42     symbolTable.EndNamespace();
 43 }
 44 
 45 void SymbolCreator::Visit(DeclarationSequenceNode& declarationSequenceNode)
 46 {
 47     declarationSequenceNode.Left()->Accept(*this);
 48     declarationSequenceNode.Right()->Accept(*this);
 49 }
 50 
 51 void SymbolCreator::Visit(LinkageSpecificationNode& linkageSpecificationNode)
 52 {
 53     linkageSpecificationNode.Declarations()->Accept(*this);
 54 }
 55 
 56 void SymbolCreator::Visit(TypedefNode& typedefNode)
 57 {
 58     nameSequence.clear();
 59     typedefNode.Declarator()->Accept(*this);
 60     if (!nameSequence.empty())
 61     {
 62         int n = symbolTable.BeginNameSequence(nameSequence);
 63         symbolTable.AddTypedef(&typedefNodenameSequence.back().firstprojectName);
 64         symbolTable.EndNameSequence(n);
 65     }
 66 }
 67 
 68 void SymbolCreator::Visit(TypeParameterNode& typeParameterNode)
 69 {
 70     std::unique_ptr<TemplateParameterSymbol> templateParameterSymbol(new TemplateParameterSymbol(typeParameterNode.GetSpan()typeParameterNode.Id()));
 71     templateParameterSymbol->SetAccess(Specifier::public_);
 72     templateParameters.push_back(std::move(templateParameterSymbol));
 73 }
 74 
 75 void SymbolCreator::Visit(TemplateParameterSequenceNode& templateParameterSequenceNode)
 76 {
 77     templateParameterSequenceNode.Left()->Accept(*this);
 78     templateParameterSequenceNode.Right()->Accept(*this);
 79 }
 80 
 81 void SymbolCreator::Visit(TemplateDeclarationNode& templateDeclarationNode)
 82 {
 83     templateParameters.clear();
 84     if (templateDeclarationNode.TemplateParameters())
 85     {
 86         templateDeclarationNode.TemplateParameters()->Accept(*this);
 87     }
 88     templateDeclarationNode.Declaration()->Accept(*this);
 89 }
 90 
 91 void SymbolCreator::Visit(ClassNode& classNode)
 92 {
 93     nameSequence.clear();
 94     classNode.ClassName()->Accept(*this);
 95     int n = symbolTable.BeginNameSequence(nameSequence);
 96     symbolTable.BeginClass(&classNodenameSequence.back().firsttemplateParametersprojectName);
 97     templateParameters.clear();
 98     if (classNode.Declarations())
 99     {
100         classNode.Declarations()->Accept(*this);
101     }
102     symbolTable.EndClass(projectName);
103     symbolTable.EndNameSequence(n);
104 }
105 
106 void SymbolCreator::Visit(MemberAccessDeclarationNode& memberAccessDeclarationNode)
107 {
108     if (memberAccessDeclarationNode.Declaration())
109     {
110         memberAccessDeclarationNode.Declaration()->Accept(*this);
111     }
112 }
113 
114 void SymbolCreator::Visit(MemberDeclarationNode& memberDeclarationNode)
115 {
116     specifiers = Specifier::none;
117     bool prevFunctionBodyFollowsOrIsPureDeletedOrDefault = functionBodyFollowsOrIsPureDeletedOrDefault;
118     bool prevWasFunctionDeclaration = wasFunctionDeclaration;
119     bool prevWasArrayDeclaration = wasArrayDeclaration;
120     wasFunctionDeclaration = false;
121     wasArrayDeclaration = false;
122     if (memberDeclarationNode.Declarator())
123     {
124         specifiers = memberDeclarationNode.Specifiers();
125         bool wasPureDeletedOrDefault = false;
126         if ((specifiers&(  Specifier::pure_ | Specifier::delete_ | Specifier::default_)) != Specifier::none)
127         {
128             wasPureDeletedOrDefault = true;
129             functionBodyFollowsOrIsPureDeletedOrDefault = true;
130         }
131         memberDeclarationNode.Declarator()->Accept(*this);
132         if (wasPureDeletedOrDefault || wasFunctionDeclaration && cpp2cmMode)
133         {
134             symbolTable.EndFunction(projectName);
135             symbolTable.EndNameSequence(nameSequenceCount);
136         }
137         if (!wasFunctionDeclaration && !wasArrayDeclaration)
138         {
139             int n = symbolTable.BeginNameSequence(nameSequence);
140             std::u32string variableName = nameSequence.back().first;
141             symbolTable.AddVariable(&memberDeclarationNodevariableNameprojectName);
142             symbolTable.EndNameSequence(n);
143         }
144     }
145     wasFunctionDeclaration = prevWasFunctionDeclaration;
146     wasArrayDeclaration = prevWasArrayDeclaration;
147     functionBodyFollowsOrIsPureDeletedOrDefault = prevFunctionBodyFollowsOrIsPureDeletedOrDefault;
148 }
149 
150 void SymbolCreator::Visit(ArrayDeclaratorNode& arrayDeclaratorNode)
151 {
152     wasArrayDeclaration = true;
153 }
154 
155 void SymbolCreator::Visit(EnumTypeNode& enumTypeNode)
156 {
157     nameSequence.clear();
158     enumTypeNode.EnumName()->Accept(*this);
159     int n = symbolTable.BeginNameSequence(nameSequence);
160     symbolTable.BeginEnumType(&enumTypeNodenameSequence.back().firstprojectName);
161     if (enumTypeNode.Enumerators())
162     {
163         enumTypeNode.Enumerators()->Accept(*this);
164     }
165     symbolTable.EndEnumType(projectName);
166     symbolTable.EndNameSequence(n);
167 }
168 
169 void SymbolCreator::Visit(EnumeratorNode& enumeratorNode)
170 {
171     symbolTable.AddEnumerator(&enumeratorNodeenumeratorNode.Enumerator()enumeratorNode.ValueStr());
172 }
173 
174 void SymbolCreator::Visit(EnumeratorSequenceNode& enumeratorSequenceNode)
175 {
176     enumeratorSequenceNode.Left()->Accept(*this);
177     enumeratorSequenceNode.Right()->Accept(*this);
178 }
179 
180 void SymbolCreator::Visit(IdentifierNode& identifierNode)
181 {
182     if (processingTemplateArguments)
183     {
184         int n = templateParameters.size();
185         for (int i = 0; i < n; ++i)
186         {
187             TypeSymbol* templateParameterSymbol = templateParameters[i].get();
188             if (templateParameterSymbol->Name() == identifierNode.Identifier())
189             {
190                 templateParameters.erase(templateParameters.begin() + i);
191                 break;
192             }
193         }
194     }
195     else
196     {
197         nameSequence.push_back(std::make_pair(identifierNode.Identifier()0));
198         groupName = identifierNode.Identifier();
199     }
200 }
201 
202 void SymbolCreator::Visit(TemplateIdNode& templateIdNode)
203 {
204     nameSequence.push_back(std::make_pair(templateIdNode.Id()->Identifier()templateIdNode.Arity()));
205     groupName = templateIdNode.Id()->Identifier();
206     if (functionBodyFollowsOrIsPureDeletedOrDefault)
207     {
208         if (templateIdNode.TemplateArguments())
209         {
210             bool prevProcessingTemplateArguments = processingTemplateArguments;
211             processingTemplateArguments = true;
212             templateIdNode.TemplateArguments()->Accept(*this);
213             processingTemplateArguments = prevProcessingTemplateArguments;
214         }
215     }
216 }
217 
218 void SymbolCreator::Visit(TemplateArgumentNode& templateArgumentNode)
219 {
220     templateArgumentNode.Arg()->Accept(*this);
221 }
222 
223 void SymbolCreator::Visit(OperatorFunctionIdNode& operatorFunctionIdNode)
224 {
225     nameSequence.push_back(std::make_pair(operatorFunctionIdNode.Str()0));
226     groupName = operatorFunctionIdNode.GroupName();
227 }
228 
229 void SymbolCreator::Visit(ConversionFunctionIdNode& conversionFunctionIdNode)
230 {
231     nameSequence.push_back(std::make_pair(U"operator_conv"0));
232     groupName = U"operator_conv";
233 }
234 
235 void SymbolCreator::Visit(NestedIdNode& nestedIdNode)
236 {
237     if (nestedIdNode.Left())
238     {
239         nestedIdNode.Left()->Accept(*this);
240     }
241     else
242     {
243         nameSequence.push_back(std::make_pair(std::u32string()0));
244     }
245     nestedIdNode.Right()->Accept(*this);
246 }
247 
248 void SymbolCreator::Visit(DtorIdNode& dDtorIdNode)
249 {
250     nameSequence.push_back(std::make_pair(U"~" + dDtorIdNode.Identifier()0));
251     groupName = U"destructor";
252 }
253 
254 void SymbolCreator::Visit(SimpleDeclarationNode& simpleDeclarationNode)
255 {
256     specifiers = Specifier::none;
257     bool prevWasFunctionDeclaration = wasFunctionDeclaration;
258     bool prevWasArrayDeclaration = wasArrayDeclaration;
259     wasFunctionDeclaration = false;
260     wasArrayDeclaration = false;
261     bool hasDeclarator = true;
262     if (simpleDeclarationNode.Declarator())
263     {
264         simpleDeclarationNode.Declarator()->Accept(*this);
265     }
266     else
267     {
268         hasDeclarator = false;
269         nameSequence.clear();
270     }
271     if (wasFunctionDeclaration && cpp2cmMode)
272     {
273         symbolTable.EndFunction(projectName);
274         symbolTable.EndNameSequence(nameSequenceCount);
275     }
276     if (!wasFunctionDeclaration && !wasArrayDeclaration)
277     {
278         int n = symbolTable.BeginNameSequence(nameSequence);
279         std::u32string variableName;
280         if (hasDeclarator)
281         {
282             variableName = nameSequence.back().first;
283         }
284         symbolTable.AddVariable(&simpleDeclarationNodevariableNameprojectName);
285         symbolTable.EndNameSequence(n);
286     }
287     wasArrayDeclaration = prevWasArrayDeclaration;
288     wasFunctionDeclaration = prevWasFunctionDeclaration;
289 }
290 
291 void SymbolCreator::Visit(InitDeclaratorNode& initDeclaratorNode)
292 {
293     initDeclaratorNode.Declarator()->Accept(*this);
294 }
295 
296 void SymbolCreator::Visit(FunctionDeclaratorNode& functionDeclaratorNode)
297 {
298     wasFunctionDeclaration = true;
299     skip = false;
300     if (functionBodyFollowsOrIsPureDeletedOrDefault || cpp2cmMode)
301     {
302         functionDeclaratorNode.Declarator()->Accept(*this);
303         if (!nameSequence.empty())
304         {
305             if (!skip)
306             {
307                 specifiers = specifiers | functionDeclaratorNode.CVSpecifiers();
308                 nameSequenceCount = symbolTable.BeginNameSequence(nameSequence);
309                 symbolTable.BeginFunction(&functionDeclaratorNodegroupNamenameSequence.back().firsttemplateParametersspecifiersprojectName);
310                 templateParameters.clear();
311                 if (functionDeclaratorNode.Parameters())
312                 {
313                     functionDeclaratorNode.Parameters()->Accept(*this);
314                 }
315             }
316         }
317     }
318     else
319     {
320         functionDeclaratorNode.Declarator()->Accept(*this);
321         if (!nameSequence.empty() && !skip)
322         {
323             specifiers = specifiers | functionDeclaratorNode.CVSpecifiers();
324             int n = symbolTable.BeginNameSequence(nameSequence);
325             symbolTable.BeginFunctionDeclaration(&functionDeclaratorNodegroupNamenameSequence.back().firsttemplateParametersspecifiersprojectName);
326             templateParameters.clear();
327             if (functionDeclaratorNode.Parameters())
328             {
329                 functionDeclaratorNode.Parameters()->Accept(*this);
330             }
331             symbolTable.EndFunctionDeclaration();
332             symbolTable.EndNameSequence(n);
333         }
334     }
335 }
336 
337 void SymbolCreator::Visit(FunctionPtrIdNode& functionPtrIdNode)
338 {
339     skip = true;
340 }
341 
342 void SymbolCreator::Visit(MemberFunctionPtrIdNode& memberFunctionPtrIdNode)
343 {
344     skip = true;
345 }
346 
347 void SymbolCreator::Visit(FunctionNode& functionNode)
348 {
349     bool prevFunctionBodyFollowsOrIsPureDeletedOrDefault = functionBodyFollowsOrIsPureDeletedOrDefault;
350     int prevNameSequenceCount = nameSequenceCount;
351     functionBodyFollowsOrIsPureDeletedOrDefault = true;
352     specifiers = functionNode.Specifiers();
353     bool wasDefaultOrDeleted = false;
354     if ((specifiers&(  Specifier::delete_ | Specifier::default_)) != Specifier::none)
355     {
356         wasDefaultOrDeleted = true;
357     }
358     functionNode.Declarator()->Accept(*this);
359     if (functionNode.Body())
360     {
361         functionNode.Body()->Accept(*this);
362         symbolTable.EndFunction(projectName);
363         symbolTable.EndNameSequence(nameSequenceCount);
364     }
365     else if (wasDefaultOrDeleted)
366     {
367         symbolTable.EndFunction(projectName);
368         symbolTable.EndNameSequence(nameSequenceCount);
369     }
370     functionBodyFollowsOrIsPureDeletedOrDefault = prevFunctionBodyFollowsOrIsPureDeletedOrDefault;
371     nameSequenceCount = prevNameSequenceCount;
372 }
373 
374 void SymbolCreator::Visit(SpecialMemberFunctionNode& specialMemberFunctionNode)
375 {
376     bool prevFunctionBodyFollowsOrIsPureDeletedOrDefault = functionBodyFollowsOrIsPureDeletedOrDefault;
377     int prevNameSequenceCount = nameSequenceCount;
378     functionBodyFollowsOrIsPureDeletedOrDefault = true;
379     bool wasDefaultOrDeleted = false;
380     specifiers = specialMemberFunctionNode.Specifiers();
381     if ((specifiers&(  Specifier::delete_ | Specifier::default_)) != Specifier::none)
382     {
383         wasDefaultOrDeleted = true;
384     }
385     specialMemberFunctionNode.Declarator()->Accept(*this);
386     if (specialMemberFunctionNode.FunctionBody())
387     {
388         specialMemberFunctionNode.FunctionBody()->Accept(*this);
389         symbolTable.EndFunction(projectName);
390         symbolTable.EndNameSequence(nameSequenceCount);
391     }
392     else if (wasDefaultOrDeleted)
393     {
394         symbolTable.EndFunction(projectName);
395         symbolTable.EndNameSequence(nameSequenceCount);
396     }
397     functionBodyFollowsOrIsPureDeletedOrDefault = prevFunctionBodyFollowsOrIsPureDeletedOrDefault;
398     nameSequenceCount = prevNameSequenceCount;
399 }
400 
401 void SymbolCreator::Visit(LabeledStatementNode& labeledStatementNode)
402 {
403     labeledStatementNode.Child()->Accept(*this);
404 }
405 
406 void SymbolCreator::Visit(CompoundStatementNode& compoundStatementNode)
407 {
408     symbolTable.BeginDeclarationBlock(&compoundStatementNode);
409     if (compoundStatementNode.Child())
410     {
411         compoundStatementNode.Child()->Accept(*this);
412     }
413     symbolTable.EndDeclarationBlock();
414 }
415 
416 void SymbolCreator::Visit(StatementSequenceNode& statementSequenceNode)
417 {
418     statementSequenceNode.Left()->Accept(*this);
419     statementSequenceNode.Right()->Accept(*this);
420 }
421 
422 void SymbolCreator::Visit(DeclarationStatementNode& declarationStatementNode)
423 {
424     declarationStatementNode.Child()->Accept(*this);
425 }
426 
427 void SymbolCreator::Visit(IfStatementNode& ifStatementNode)
428 {
429     symbolTable.BeginDeclarationBlock(&ifStatementNode);
430     ifStatementNode.Condition()->Accept(*this);
431     ifStatementNode.ThenS()->Accept(*this);
432     if (ifStatementNode.ElseS())
433     {
434         ifStatementNode.ElseS()->Accept(*this);
435     }
436     symbolTable.EndDeclarationBlock();
437 }
438 
439 void SymbolCreator::Visit(SwitchStatementNode& switchStatementNode)
440 {
441     symbolTable.BeginDeclarationBlock(&switchStatementNode);
442     switchStatementNode.Condition()->Accept(*this);
443     switchStatementNode.Statement()->Accept(*this);
444     symbolTable.EndDeclarationBlock();
445 }
446 
447 void SymbolCreator::Visit(CaseStatementNode& caseStatementNode)
448 {
449     caseStatementNode.Child()->Accept(*this);
450 }
451 
452 void SymbolCreator::Visit(DefaultStatementNode& defaultStatementNode)
453 {
454     defaultStatementNode.Child()->Accept(*this);
455 }
456 
457 void SymbolCreator::Visit(WhileStatementNode& whileStatementNode)
458 {
459     symbolTable.BeginDeclarationBlock(&whileStatementNode);
460     whileStatementNode.Condition()->Accept(*this);
461     whileStatementNode.Statement()->Accept(*this);
462     symbolTable.EndDeclarationBlock();
463 }
464 
465 void SymbolCreator::Visit(DoStatementNode& doStatementNode)
466 {
467     doStatementNode.Statement()->Accept(*this);
468 }
469 
470 void SymbolCreator::Visit(RangeForStatementNode& rangeForStatementNode)
471 {
472     symbolTable.BeginDeclarationBlock(&rangeForStatementNode);
473     rangeForStatementNode.ForRangeDeclaration()->Accept(*this);
474     rangeForStatementNode.Statement()->Accept(*this);
475     symbolTable.EndDeclarationBlock();
476 }
477 
478 void SymbolCreator::Visit(ForStatementNode& forStatementNode)
479 {
480     symbolTable.BeginDeclarationBlock(&forStatementNode);
481     if (forStatementNode.InitS())
482     {
483         forStatementNode.InitS()->Accept(*this);
484     }
485     if (forStatementNode.Condition())
486     {
487         forStatementNode.Condition()->Accept(*this);
488     }
489     forStatementNode.ActionS()->Accept(*this);
490     symbolTable.EndDeclarationBlock();
491 }
492 
493 void SymbolCreator::Visit(ReturnStatementNode& returnStatementNode)
494 {
495     if (returnStatementNode.ReturnExpr())
496     {
497         returnStatementNode.ReturnExpr()->Accept(*this);
498     }
499 }
500 
501 void SymbolCreator::Visit(TryStatementNode& tryStatementNode)
502 {
503     tryStatementNode.TryBlock()->Accept(*this);
504     tryStatementNode.Handlers()->Accept(*this);
505 }
506 
507 void SymbolCreator::Visit(HandlerNode& handlerNode)
508 {
509     symbolTable.BeginDeclarationBlock(&handlerNode);
510     handlerNode.ExceptionDeclaration()->Accept(*this);
511     handlerNode.CatchBlock()->Accept(*this);
512     symbolTable.EndDeclarationBlock();
513 }
514 
515 void SymbolCreator::Visit(HandlerSequenceNode& handlerSequenceNode)
516 {
517     handlerSequenceNode.Left()->Accept(*this);
518     handlerSequenceNode.Right()->Accept(*this);
519 }
520 
521 void SymbolCreator::Visit(IdDeclaratorNode& idDeclaratorNode)
522 {
523     nameSequence.clear();
524     idDeclaratorNode.IdNode()->Accept(*this);
525 }
526 
527 void SymbolCreator::Visit(ParameterNode& parameterNode)
528 {
529     std::u32string parameterName;
530     if (parameterNode.Declarator())
531     {
532         parameterNode.Declarator()->Accept(*this);
533         parameterName = nameSequence.back().first;
534     }
535     else
536     {
537         nameSequence.clear();
538     }
539     int n = symbolTable.BeginNameSequence(nameSequence);
540     symbolTable.AddParameter(&parameterNodeparameterName);
541     symbolTable.EndNameSequence(n);
542 }
543 
544 void SymbolCreator::Visit(ParameterSequenceNode& parameterSequenceNode)
545 {
546     parameterSequenceNode.Left()->Accept(*this);
547     parameterSequenceNode.Right()->Accept(*this);
548 }
549 
550 void SymbolCreator::Visit(ExpressionStatementNode& expressionStatementNode)
551 {
552     nameSequence.clear();
553     if (expressionStatementNode.Child())
554     {
555         expressionStatementNode.Child()->Accept(*this);
556     }
557 }
558 
559 void SymbolCreator::Visit(CommaExpressionNode& commaExpressionNode)
560 {
561     commaExpressionNode.Left()->Accept(*this);
562     commaExpressionNode.Right()->Accept(*this);
563 }
564 
565 void SymbolCreator::Visit(AssignmentExpressionNode& assignmentExpressionNode)
566 {
567     assignmentExpressionNode.Left()->Accept(*this);
568     assignmentExpressionNode.Right()->Accept(*this);
569 }
570 
571 void SymbolCreator::Visit(ConditionalExpressionNode& conditionalExpressionNode)
572 {
573     conditionalExpressionNode.Condition()->Accept(*this);
574     conditionalExpressionNode.ThenExpr()->Accept(*this);
575     conditionalExpressionNode.ElseExpr()->Accept(*this);
576 }
577 
578 void SymbolCreator::Visit(ThrowExpressionNode& throwExpressionNode)
579 {
580     if (throwExpressionNode.Child())
581     {
582         throwExpressionNode.Child()->Accept(*this);
583     }
584 }
585 
586 void SymbolCreator::Visit(LogicalOrExpressionNode& logicalOrExpressionNode)
587 {
588     logicalOrExpressionNode.Left()->Accept(*this);
589     logicalOrExpressionNode.Right()->Accept(*this);
590 }
591 
592 void SymbolCreator::Visit(LogicalAndExpressionNode& logicalAndExpressionNode)
593 {
594     logicalAndExpressionNode.Left()->Accept(*this);
595     logicalAndExpressionNode.Right()->Accept(*this);
596 }
597 
598 void SymbolCreator::Visit(InclusiveOrExpressionNode& inclusiveOrExpressionNode)
599 {
600     inclusiveOrExpressionNode.Left()->Accept(*this);
601     inclusiveOrExpressionNode.Right()->Accept(*this);
602 }
603 
604 void SymbolCreator::Visit(ExclusiveOrExpressionNode& exclusiveOrExpressionNode)
605 {
606     exclusiveOrExpressionNode.Left()->Accept(*this);
607     exclusiveOrExpressionNode.Right()->Accept(*this);
608 }
609 
610 void SymbolCreator::Visit(AndExpressionNode& andExpressionNode)
611 {
612     andExpressionNode.Left()->Accept(*this);
613     andExpressionNode.Right()->Accept(*this);
614 }
615 
616 void SymbolCreator::Visit(EqualityExpressionNode& equalityExpressionNode)
617 {
618     equalityExpressionNode.Left()->Accept(*this);
619     equalityExpressionNode.Right()->Accept(*this);
620 }
621 
622 void SymbolCreator::Visit(RelationalExpressionNode& relationalExpressionNode)
623 {
624     relationalExpressionNode.Left()->Accept(*this);
625     relationalExpressionNode.Right()->Accept(*this);
626 }
627 
628 void SymbolCreator::Visit(ShiftExpressionNode& shiftExpressionNode)
629 {
630     shiftExpressionNode.Left()->Accept(*this);
631     shiftExpressionNode.Right()->Accept(*this);
632 }
633 
634 void SymbolCreator::Visit(AdditiveExpressionNode& additiveExpressionNode)
635 {
636     additiveExpressionNode.Left()->Accept(*this);
637     additiveExpressionNode.Right()->Accept(*this);
638 }
639 
640 void SymbolCreator::Visit(MultiplicativeExpressionNode& multiplicativeExpressionNode)
641 {
642     multiplicativeExpressionNode.Left()->Accept(*this);
643     multiplicativeExpressionNode.Right()->Accept(*this);
644 }
645 
646 void SymbolCreator::Visit(PMExpressionNode& pmExpressionNode)
647 {
648     pmExpressionNode.Left()->Accept(*this);
649     pmExpressionNode.Right()->Accept(*this);
650 }
651 
652 void SymbolCreator::Visit(CastExpressionNode& castExpressionNode)
653 {
654     castExpressionNode.TypeExpr()->Accept(*this);
655     castExpressionNode.Expr()->Accept(*this);
656 }
657 
658 void SymbolCreator::Visit(UnaryExpressionNode& unaryExpressionNode)
659 {
660     unaryExpressionNode.Child()->Accept(*this);
661 }
662 
663 void SymbolCreator::Visit(NewExpressionNode& newExpressionNode)
664 {
665     if (newExpressionNode.Placement())
666     {
667         newExpressionNode.Placement()->Accept(*this);
668     }
669     newExpressionNode.TypeExpr()->Accept(*this);
670     if (newExpressionNode.Initializer())
671     {
672         newExpressionNode.Initializer()->Accept(*this);
673     }
674 }
675 
676 void SymbolCreator::Visit(DeleteExpressionNode& deleteExpressionNode)
677 {
678     deleteExpressionNode.Child()->Accept(*this);
679 }
680 
681 void SymbolCreator::Visit(SubscriptExpressionNode& subscriptExpressionNode)
682 {
683     subscriptExpressionNode.Child()->Accept(*this);
684     subscriptExpressionNode.Index()->Accept(*this);
685 }
686 
687 void SymbolCreator::Visit(DotNode& dotNode)
688 {
689     nameSequence.clear();
690     dotNode.Child()->Accept(*this);
691     nameSequence.clear();
692     dotNode.Id()->Accept(*this);
693 }
694 
695 void SymbolCreator::Visit(InvokeExpressionNode& invokeExpressionNode)
696 {
697     invokeExpressionNode.Child()->Accept(*this);
698     if (invokeExpressionNode.Arguments())
699     {
700         invokeExpressionNode.Arguments()->Accept(*this);
701     }
702 }
703 
704 void SymbolCreator::Visit(AssignmentInitializerNode& assignmentInitializerNode)
705 {
706     assignmentInitializerNode.Child()->Accept(*this);
707 }
708 
709 void SymbolCreator::Visit(ExpressionListInitializerNode& expressionListInitializerNode)
710 {
711     expressionListInitializerNode.Child()->Accept(*this);
712 }
713 
714 void SymbolCreator::Visit(ExpressionInitializerNode& expressionInitializerNode)
715 {
716     expressionInitializerNode.Child()->Accept(*this);
717 }
718 
719 void SymbolCreator::Visit(BracedInitializerListNode& bracedInitializerListNode)
720 {
721     bracedInitializerListNode.Child()->Accept(*this);
722 }
723 
724 void SymbolCreator::Visit(ExpressionSequenceNode& expressionSequenceNode)
725 {
726     expressionSequenceNode.Left()->Accept(*this);
727     expressionSequenceNode.Right()->Accept(*this);
728 }
729 
730 void SymbolCreator::Visit(LambdaExpressionNode& lambdaExpressionNode)
731 {
732     symbolTable.BeginLambdaExpression(&lambdaExpressionNode);
733     if (lambdaExpressionNode.Captures())
734     {
735         lambdaExpressionNode.Captures()->Accept(*this);
736     }
737     if (lambdaExpressionNode.Parameters())
738     {
739         lambdaExpressionNode.Parameters()->Accept(*this);
740     }
741     lambdaExpressionNode.Body()->Accept(*this);
742     symbolTable.EndLambdaExpression();
743 }
744 
745 void SymbolCreator::Visit(CaptureSequenceNode& captureSequenceNode)
746 {
747     captureSequenceNode.Left()->Accept(*this);
748     captureSequenceNode.Right()->Accept(*this);
749 }
750 
751 void SymbolCreator::Visit(IdentifierCaptureNode& identifierCaptureNode)
752 {
753     identifierCaptureNode.Child()->Accept(*this);
754 }
755 
756 } } // namespace sngcpp::symbols