public override ASTNode VisitFunctionCall([NotNull] DaedalusParser.FunctionCallContext context) { DaedalusParser.NameNodeContext nameNodeContext = context.nameNode(); ReferenceNode referenceNode = new ReferenceNode(nameNodeContext.GetText(), GetLocation(nameNodeContext)); ReferenceNodes.Add(referenceNode); List <ExpressionNode> expressionNodes = new List <ExpressionNode>(); foreach (DaedalusParser.ExpressionContext expressionContext in context.expression()) { expressionNodes.Add((ExpressionNode)Visit(expressionContext)); } return(new FunctionCallNode(GetLocation(context), referenceNode, expressionNodes)); }
private VarDeclarationsTemporaryNode GetVarDeclarationsTemporaryNode(DaedalusParser.VarDeclContext varDeclContext) { NameNode typeNameNode = new NameNode(GetLocation(varDeclContext.dataType()), varDeclContext.dataType().GetText()); List <DeclarationNode> varDeclarationNodes = new List <DeclarationNode>(); foreach (IParseTree childContext in varDeclContext.children) { if (childContext is DaedalusParser.VarValueDeclContext varValueDeclContext) { DaedalusParser.NameNodeContext nameNodeContext = varValueDeclContext.nameNode(); NameNode nameNode = new NameNode(GetLocation(nameNodeContext), nameNodeContext.GetText()); ExpressionNode rightSideNode = null; if (varValueDeclContext.varValueAssignment() != null) { rightSideNode = (ExpressionNode)Visit(varValueDeclContext.varValueAssignment().expression()); // TODO check if null } varDeclarationNodes.Add(new VarDeclarationNode(GetLocation(varValueDeclContext), typeNameNode, nameNode, rightSideNode)); } else if (childContext is DaedalusParser.VarArrayDeclContext varArrayDeclContext) { DaedalusParser.NameNodeContext nameNodeContext = varArrayDeclContext.nameNode(); NameNode nameNode = new NameNode(GetLocation(nameNodeContext), nameNodeContext.GetText()); ExpressionNode arraySizeNode = (ExpressionNode)VisitArraySize(varArrayDeclContext.arraySize()); List <ExpressionNode> elementNodes = null; if (varArrayDeclContext.varArrayAssignment() != null) { elementNodes = new List <ExpressionNode>(); foreach (DaedalusParser.ExpressionContext expressionContext in varArrayDeclContext.varArrayAssignment().expression()) { elementNodes.Add((ExpressionNode)Visit(expressionContext)); } } VarArrayDeclarationNode varArrayDeclarationNode = new VarArrayDeclarationNode(GetLocation(nameNodeContext), typeNameNode, nameNode, arraySizeNode, elementNodes); // TODO check if null _arrayDeclarationNodes.Add(varArrayDeclarationNode); varDeclarationNodes.Add(varArrayDeclarationNode); } } return(new VarDeclarationsTemporaryNode(GetLocation(varDeclContext), varDeclarationNodes)); }
private ConstDefinitionsTemporaryNode GetConstDefinitionsTemporaryNode(DaedalusParser.ConstDefContext constDefContext) { NameNode typeNameNode = new NameNode(GetLocation(constDefContext.dataType()), constDefContext.dataType().GetText()); List <DeclarationNode> constDefinitionNodes = new List <DeclarationNode>(); foreach (IParseTree childContext in constDefContext.children) { if (childContext is DaedalusParser.ConstValueDefContext constValueDefContext) { DaedalusParser.NameNodeContext nameNodeContext = constValueDefContext.nameNode(); NameNode nameNode = new NameNode(GetLocation(nameNodeContext), nameNodeContext.GetText()); ExpressionNode rightSideNode = (ExpressionNode)Visit(constValueDefContext.constValueAssignment().expression()); ConstDefinitionNode constDefinitionNode = new ConstDefinitionNode(GetLocation(constValueDefContext), typeNameNode, nameNode, rightSideNode); _constDefinitionNodes.Add(constDefinitionNode); constDefinitionNodes.Add(constDefinitionNode); } else if (childContext is DaedalusParser.ConstArrayDefContext constArrayDefContext) { DaedalusParser.NameNodeContext nameNodeContext = constArrayDefContext.nameNode(); NameNode nameNode = new NameNode(GetLocation(nameNodeContext), nameNodeContext.GetText()); ExpressionNode arraySizeNode = (ExpressionNode)VisitArraySize(constArrayDefContext.arraySize()); List <ExpressionNode> elementNodes = new List <ExpressionNode>(); foreach (DaedalusParser.ExpressionContext expressionContext in constArrayDefContext.constArrayAssignment().expression()) { elementNodes.Add((ExpressionNode)Visit(expressionContext)); } ConstArrayDefinitionNode constArrayDefinitionNode = new ConstArrayDefinitionNode(GetLocation(nameNodeContext), typeNameNode, nameNode, arraySizeNode, elementNodes); _arrayDeclarationNodes.Add(constArrayDefinitionNode); constDefinitionNodes.Add(constArrayDefinitionNode); } } return(new ConstDefinitionsTemporaryNode(GetLocation(constDefContext), constDefinitionNodes)); }