public override void Visit(RunQueryNode node)
        {
            var Type = SymbolTable.FunctionReturnType(node.FunctionName);

            if (Type == null)
            {
                SymbolTable.UndeclaredFunction(node.FunctionName);
            }
            VisitChildren(node);
        }
Exemple #2
0
        public override AbstractNode VisitRunFunction([NotNull] GiraphParser.RunFunctionContext context)
        {
            RunQueryNode node = new RunQueryNode(context.Start.Line, context.Start.Column);

            node.FunctionName = context.variable().GetText();
            foreach (var item in context.varOrConst())
            {
                if (item.variable() != null)
                {
                    VariableNode varNode = new VariableNode(context.Start.Line, context.Start.Column);
                    varNode.Name = item.variable().GetText();
                    node.AdoptChildren(varNode);
                }
                else
                {
                    ConstantNode conNode = new ConstantNode(context.Start.Line, context.Start.Column);
                    conNode.Value = item.constant().GetText();
                    conNode.Type  = ExpressionPartTypeFinder(item.constant().GetChild(0)).ToString();
                    node.AdoptChildren(conNode);
                }
            }
            return(node);
        }
 public override void Visit(RunQueryNode node)
 {
 }
Exemple #4
0
        public override void Visit(RunQueryNode node)
        {
            _symbolTable.SetCurrentNode(node);
            node.Type = _symbolTable.RetrieveSymbol(node.FunctionName).ToString().ToLower();
            bool isCollection = false;

            VisitChildren(node);
            List <FunctionParameterEntry> funcParamList = _symbolTable.GetParameterTypes(node.FunctionName);

            funcParamList.OrderBy(x => x.ID);
            int     i = 0;
            AllType placeholderType = AllType.UNKNOWNTYPE;

            if (node.Parent is ExpressionNode expNode)
            {
                expNode.OverAllType = _symbolTable.RetrieveSymbol(node.FunctionName);
            }

            if (node.Children.Count > 0)
            {
                if (node.Children.Count <= funcParamList.Count)
                {
                    foreach (AbstractNode child in node.Children)
                    {
                        if (child is VariableNode varNode)
                        {
                            placeholderType = _symbolTable.RetrieveSymbol(child.Name, out isCollection) ?? AllType.UNKNOWNTYPE;

                            if (funcParamList.Count > 0)
                            {
                                if (placeholderType != funcParamList[i].Type && funcParamList[i].Collection == isCollection)
                                {
                                    //type error
                                    _symbolTable.RunFunctionTypeError(child.Name, funcParamList[i].Name);
                                }
                            }
                            else
                            {
                                //calling function with no formal parameters
                                _symbolTable.RunFunctionParameterError();
                            }
                        }
                        else if (child is ConstantNode constNode)
                        {
                            if (funcParamList.Count == 0)
                            {
                                _symbolTable.RunFunctionParameterError();
                            }
                            else
                            {
                                if (child.Type_enum != funcParamList[i].Type)
                                {
                                    _symbolTable.RunFunctionTypeError(child.Name, funcParamList[i].Name);
                                    //type error
                                }
                            }
                        }
                        ++i;
                    }
                }
                else
                {
                    _symbolTable.RunFunctionParameterError();
                }
            }
            else if (funcParamList.Count > 0)
            {
                //running function without actual parameters, when function has formal parameters
                _symbolTable.RunFunctionParameterError();
            }
        }
 public abstract void Visit(RunQueryNode node);