protected ASTNode(NodeLocation location)
 {
     Annotations = new List <NodeAnnotation>();
     Location    = location;
     _firstSignificantAncestorNode = null;
 }
        protected virtual void Visit(ASTNode node)
        {
            switch (node)
            {
            case FileNode fileNode:
                VisitFile(fileNode);
                break;

            case FunctionDefinitionNode functionDefinitionNode:
                VisitFunctionDefinition(functionDefinitionNode);
                break;

            case AssignmentNode assignmentNode:
                VisitAssignment(assignmentNode);
                break;

            case CompoundAssignmentNode compoundAssignmentNode:
                VisitCompoundAssignment(compoundAssignmentNode);
                break;

            case UnaryExpressionNode unaryExpressionNode:
                VisitUnaryExpression(unaryExpressionNode);
                break;

            case BinaryExpressionNode binaryExpressionNode:
                VisitBinaryExpression(binaryExpressionNode);
                break;

            case ClassDefinitionNode classDefinitionNode:
                VisitClassDefinition(classDefinitionNode);
                break;

            case PrototypeDefinitionNode prototypeDefinitionNode:
                VisitPrototypeDefinition(prototypeDefinitionNode);
                break;

            case InstanceDefinitionNode instanceDefinitionNode:
                VisitInstanceDefinition(instanceDefinitionNode);
                break;

            case ConstArrayDefinitionNode constArrayDefinitionNode:
                VisitConstArrayDefinition(constArrayDefinitionNode);
                break;

            case ConstDefinitionNode constDefinitionNode:
                VisitConstDefinition(constDefinitionNode);
                break;

            case ParameterArrayDeclarationNode parameterArrayDeclarationNode:
                VisitParameterArrayDeclaration(parameterArrayDeclarationNode);
                break;

            case ParameterDeclarationNode parameterDeclarationNode:
                VisitParameterDeclaration(parameterDeclarationNode);
                break;

            case VarArrayDeclarationNode varArrayDeclarationNode:
                VisitVarArrayDeclaration(varArrayDeclarationNode);
                break;

            case VarDeclarationNode varDeclarationNode:
                VisitVarDeclaration(varDeclarationNode);
                break;

            case ReturnStatementNode returnStatementNode:
                VisitReturnStatement(returnStatementNode);
                break;

            case BreakStatementNode breakStatementNode:
                VisitBreakStatement(breakStatementNode);
                break;

            case ContinueStatementNode continueStatementNode:
                VisitContinueStatement(continueStatementNode);
                break;

            case FunctionCallNode functionCallNode:
                VisitFunctionCall(functionCallNode);
                break;

            case IfStatementNode ifStatementNode:
                VisitIfStatement(ifStatementNode);
                break;

            case WhileStatementNode whileStatementNode:
                VisitWhileStatement(whileStatementNode);
                break;

            case IntegerLiteralNode integerLiteralNode:
                VisitIntegerLiteral(integerLiteralNode);
                break;

            case FloatLiteralNode floatLiteralNode:
                VisitFloatLiteral(floatLiteralNode);
                break;

            case StringLiteralNode stringLiteralNode:
                VisitStringLiteral(stringLiteralNode);
                break;

            case NoFuncNode noFuncNode:
                VisitNoFunc(noFuncNode);
                break;

            case NullNode nullNode:
                VisitNull(nullNode);
                break;

            case ReferenceNode referenceNode:
                VisitReference(referenceNode);
                break;

            case ArrayIndexNode arrayIndexNode:
                VisitArrayIndexNode(arrayIndexNode);
                break;

            case NameNode nameNode:
                VisitName(nameNode);
                break;

            case ConditionalNode conditionalNode:
                VisitConditional(conditionalNode);
                break;
            }
        }
示例#3
0
 private void CheckArrayElementType(SymbolType expectedType, SymbolType actualType, ASTNode node)
 {
     try
     {
         CheckType(expectedType, actualType);
     }
     catch (IncompatibleTypesException)
     {
         node.Annotations.Add(new CannotInitializeArrayElementWithValueOfDifferentTypeError(node.Location, expectedType, actualType));
     }
 }