Ejemplo n.º 1
0
        protected virtual void BuildExpression(ParsingContext context, ParseTreeNode treeNode)
        {
            token = treeNode.ChildNodes[0].Token as Token;
            if (token != null && token.Terminal is Tokenizer)         // terminals do not need to be rechecked
            {
                SetUoToken(((Tokenizer)token.Terminal).Tokenize(token.Value));
                SetUoTypeToken(((Tokenizer)token.Terminal).TokenType);
                AsString = treeNode.ChildNodes[0].Token.ValueString;
            }
            else
            {
                foreach (ParseTreeNode cnode in treeNode.ChildNodes)
                {
                    if (cnode.AstNode is ExpressionNode)
                    {
                        AstNode node = Reduce(cnode); // (ExpressionNode)cnode.AstNode;
                        ChildNodes.Add(node);
                        node.Parent = this;
                    }
                }

                // Nulls in a list are ok on the first pass, but not on the second, so this is only done here if there are no null types
                if (ChildNodes.Count == 1 || ChildNodes.TrueForAll(node => ((ExpressionNode)node).UoTypeToken != null))
                {
                    CheckScope(context);
                }
            }
        }