/// <summary>
        /// This function will return true if it doesn't encounter any problems.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="logErrors"></param>
        /// <returns></returns>
        public bool Analyse(Node node)
        {
            var        result = true;
            string     id     = "";
            QValueType type   = QValueType.UNKNOWN;

            if (node.Type == NodeType.QUESTION)
            {
                var questionNode = (QuestionNode)node;
                id   = questionNode.ID;
                type = questionNode.ValueType;
                return(AddVariable(id, type));
            }
            else if (node.Type == NodeType.COMPUTED)
            {
                var computedNode = (ComputedNode)node;
                id   = computedNode.ID;
                type = computedNode.ValueType;
                return(AddVariable(id, type));
            }

            // Set result to false if any of the children encounters an error.
            foreach (Node child in node.Children)
            {
                if (!Analyse(child) && result)
                {
                    result = false;
                }
            }

            return(result);
        }
示例#2
0
 public ComputedNode(Location location, string id, string text, QValueType valueType, IExpressionNode expression) : base(location, NodeType.COMPUTED)
 {
     this.ID         = id;
     this.Text       = text;
     this.ValueType  = valueType;
     this.Expression = expression;
 }
示例#3
0
        /// <summary>
        /// This function adds a variable to the SymbolTable. In case of an error a message will
        /// be added to the analyser.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        public static bool Add(string id, QValueType type)
        {
            if (!Instance.TypeMap.ContainsKey(id))
            {
                Instance.TypeMap.Add(id, type);
                return(true);
            }

            return(false);
        }
        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);
        }
示例#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);
        }
示例#6
0
 public QLSStyle(QValueType type, QLSWidgetSpecification specification) : this(type)
 {
     this.WidgetSpecification = specification;
 }
示例#7
0
 public QLSStyle(QValueType type) : this()
 {
     this.QValueType = type;
 }
示例#8
0
 public QuestionNode(Location location, string id, string text, QValueType questionType) : base(location, NodeType.Question)
 {
     this.ID        = id;
     this.Text      = text;
     this.ValueType = questionType;
 }
示例#9
0
 public LiteralNode(Location location, string value, QValueType qValueType) : base(location, NodeType.LITERAL)
 {
     this.Value      = value;
     this.QValueType = qValueType;
 }
示例#10
0
 public QLSValue(string property, string value, QValueType qValueType)
 {
     this.StyleProperty = property;
     this.StyleValue    = value;
     this.QValueType    = qValueType;
 }