/// <summary>
        /// A recursive function to find out if the AST contains multiple FormNode
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public bool Analyse(QLNode node)
        {
            //Reset the formNodeCount
            formNodeCount = 0;
            if (node.Type == NodeType.Form)
            {
                this.Visit(node as FormNode);
            }
            else
            {
                this.Visit(node);
            }

            this.Visit(node);

            if (formNodeCount == 0)
            {
                Analyser.AddMessage("There has no form been defined", Language.QL, MessageType.ERROR);
            }
            else if (formNodeCount > 1)
            {
                Analyser.AddMessage("There can only be one form", Language.QL, MessageType.ERROR);
            }

            return(formNodeCount == 1);
        }
        public bool Analyse(QLNode node)
        {
            var result     = true;
            var expression = GetExpression(node);

            if (expression != null && AnalyseExpression(expression) == StatementType.Unknown)
            {
                Analyser.AddMessage(string.Format("{0} - This expression isn't valid.", node.Location), Language.QL, MessageType.ERROR);
                return(false);
            }

            switch (node)
            {
            case QLCollectionNode collectionNode:
                foreach (QLNode child in collectionNode.Children)
                {
                    if (!Analyse(child))
                    {
                        result = false;
                    }
                }
                break;

            default:
                return(true);
            }

            return(result);
        }
        public bool AddVariable(string id, QValueType type)
        {
            if (!SymbolTable.Add(id, type))
            {
                Analyser.AddMessage(string.Format("Duplicate identifier {0} {1}", id, type), MessageType.ERROR);
                return(false);
            }

            return(true);
        }
        public void Visit(QuestionNode node)
        {
            if (node.Children.Count != 0)
            {
                isValid = false;
                Analyser.AddMessage(errorMessage, LanguageType.QL, MessageType.ERROR);
            }

            VisitChildren(node);
        }
Beispiel #5
0
        private bool AddVariable(string id, QValueType type)
        {
            VisitedIDs.Add(id);
            if (!SymbolTable.Add(id, type))
            {
                Analyser.AddMessage(string.Format("Duplicate identifier {0} {1}", id, type), Language.QL, MessageType.ERROR);
                return(false);
            }

            return(true);
        }
        private bool IsIdentiierInSymbolTable(IdentifierNode node)
        {
            var valueType = SymbolTable.Get(node.ID);

            if (valueType != QValueType.Unknown)
            {
                return(true);
            }
            else
            {
                Analyser.AddMessage(string.Format("{0} Unknown identifier '{1}' in statement", node.Location, node.ID), Language.QL, MessageType.ERROR);
                return(false);
            }
        }
Beispiel #7
0
        public bool Analyse(QLSNode node)
        {
            this._visitedNodes.Clear();
            this.Visit(node);
            var isValid = true;

            foreach (var visitedNode in _visitedNodes)
            {
                if (!SymbolTable.Instance.TypeMap.Keys.Contains(visitedNode.ID))
                {
                    Analyser.AddMessage(string.Format("{0} Unknown identifier in QLS: {1}", visitedNode.Location, visitedNode.ID), Language.QLS, MessageType.ERROR);
                    isValid = false;
                }
            }

            return(isValid);
        }
        public bool Analyse(QLSNode node)
        {
            var isValid = true;

            this._visitedNodes.Clear();
            this.Visit(node);

            foreach (var key in SymbolTable.Instance.TypeMap.Keys)
            {
                if (!this._visitedNodes.Select(x => x.ID).Contains(key))
                {
                    Analyser.AddMessage(string.Format("Identifier has not been included in QLS: {0}", key), Language.QLS, MessageType.WARNING);
                    isValid = false;
                }
            }

            return(isValid);
        }
Beispiel #9
0
        public bool Analyse(Node node)
        {
            var childValue = true;

            foreach (Node child in node.Children)
            {
                if (child.Type == NodeType.QUESTION && child.Children.Count != 0)
                {
                    Analyser.AddMessage(errorMessage, MessageType.ERROR);
                    return(false);
                }
                else
                {
                    childValue = Analyse(child);
                }
            }

            return(childValue);
        }
Beispiel #10
0
        public bool Analyse(QLSNode node)
        {
            this._visitedNodes.Clear();
            this.Visit(node);

            var isValid = true;

            foreach (var visitedNode in this._visitedNodes)
            {
                var idCount = this._visitedNodes.Count(x => x.ID == visitedNode.ID);
                if (idCount > 1)
                {
                    isValid = false;
                    Analyser.AddMessage(string.Format("{0} Duplicate key in QLS: {1}", visitedNode.Location, visitedNode.ID), Language.QLS, MessageType.WARNING);
                }
            }

            return(isValid);
        }
        public bool Analyse(Node node)
        {
            var result     = true;
            var expression = GetExpression(node);

            if (expression != null && AnalyseExpression(expression) == StatementType.UNKNOWN)
            {
                Analyser.AddMessage(string.Format("{0} - This expression isn't valid.", node.Location), MessageType.ERROR);
                return(false);
            }

            foreach (Node child in node.Children)
            {
                if (!Analyse(child))
                {
                    result = false;
                }
            }

            return(result);
        }