コード例 #1
0
        public INode Match(Lookahead2Enumerator <Token> it, IGrammarParser parser)
        {
            if (!this.open.Equals(it.PeekNext()))
            {
                return(null);
            }
            it.Consume();
            if (this.close.Equals(it.PeekNext()))
            {
                it.Consume();
                return(this.nf.BuildOperatorNode(this.list, new INode[0]));
            }
            List <INode> list = new List <INode>();

            while (true)
            {
                INode item = parser.ParseSubExpression();
                list.Add(item);
                if (this.close.Equals(it.PeekNext()))
                {
                    it.Consume();
                    return(this.nf.BuildOperatorNode(this.list, list.ToArray()));
                }
                if (!this.comma.Equals(it.PeekNext()))
                {
                    break;
                }
                it.Consume();
            }
            throw new Colosoft.Text.Jep.ParseException("Closing bracket not found");
        }
コード例 #2
0
        public INode Match(Lookahead2Enumerator <Token> it, IGrammarParser parser)
        {
            Token token = it.PeekNext();

            if (token == null)
            {
                return(null);
            }
            if (!token.IsIdentifier())
            {
                return(null);
            }
            if (!this.open.Equals(it.PeekNextnext()))
            {
                return(null);
            }
            it.Consume();
            ArrayList list = new ArrayList(4);

            list.Add(this.nf.BuildVariableNodeCheckUndeclared(token.GetSource()));
            while (this.open.Equals(it.PeekNext()))
            {
                it.Consume();
                INode node = parser.ParseSubExpression();
                list.Add(node);
                if (!this.close.Equals(it.PeekNext()))
                {
                    throw new Colosoft.Text.Jep.ParseException("Closing bracket not found, next token is " + it.PeekNext());
                }
                it.Consume();
            }
            INode[] arguments = new INode[list.Count];
            arguments = (INode[])list.ToArray(Type.GetType("Colosoft.Text.Jep.Parser.INode"));
            return(this.nf.BuildOperatorNode(this.ot.GetOperator(0x17), arguments));
        }
コード例 #3
0
        public INode Match(Lookahead2Enumerator <Token> it, IGrammarParser parser)
        {
            Token token = it.PeekNext();

            if (token == null)
            {
                return(null);
            }
            if (!token.IsFunction())
            {
                return(null);
            }
            string source            = token.GetSource();
            IPostfixMathCommand pfmc = ((FunctionToken)token).GetPfmc();

            if (!this.open.Equals(it.PeekNextnext()))
            {
                return(null);
            }
            it.Consume();
            it.Consume();
            if (this.close.Equals(it.PeekNext()))
            {
                if (!pfmc.CheckNumberOfParameters(0))
                {
                    throw new Colosoft.Text.Jep.ParseException("Function " + pfmc + " invalid number of arguments 0");
                }
                it.Consume();
                return(this.nf.BuildFunctionNode(source, pfmc, new INode[0]));
            }
            List <INode> list = new List <INode>();

            while (true)
            {
                INode item = parser.ParseSubExpression();
                list.Add(item);
                if (this.close.Equals(it.PeekNext()))
                {
                    it.Consume();
                    if (!pfmc.CheckNumberOfParameters(list.Count))
                    {
                        throw new Colosoft.Text.Jep.ParseException(string.Concat(new object[] {
                            "Function ",
                            pfmc,
                            " invalid number of arguments ",
                            list.Count
                        }));
                    }
                    return(this.nf.BuildFunctionNode(source, pfmc, list.ToArray()));
                }
                if (!this.comma.Equals(it.PeekNext()))
                {
                    break;
                }
                it.Consume();
            }
            throw new Colosoft.Text.Jep.ParseException("Closing bracket not found. Next token is " + it.PeekNext());
        }
コード例 #4
0
        public INode Match(Lookahead2Enumerator <Token> it, IGrammarParser parser)
        {
            if (!this.open.Equals(it.PeekNext()))
            {
                return(null);
            }
            it.Consume();
            INode node = parser.ParseSubExpression();

            if (!this.close.Equals(it.PeekNext()))
            {
                throw new Colosoft.Text.Jep.ParseException("Closing bracket not found");
            }
            it.Consume();
            return(node);
        }