Ejemplo n.º 1
0
 public FuncNode(string name, Expression[] children, Operator oper)
 {
     CheckBeforeAccept(children);
     this.children = children;
     this.@operator = oper;
     this.name = name;
 }
 private static Operator[] GetOperatorsFromLexeme(Operator[] ops, Lexeme lex)
 {
     AList<Operator> list = new AList<Operator>();
     foreach (Operator op in ops)
     {
         if (lex.GetType() == Lexeme.OPERATOR && lex.GetValue().Equals(op.symbol))
         {
             list.AddItem(op);
         }
     }
     return Sharpen.Collections.ToArray(list, new Operator[list.Count]);
 }
        private static Operator GetOperatorFromLexeme(Operator[] ops, Lexeme lex, bool isBinary
			)
        {
            foreach (Operator op in ops)
            {
                if (lex.GetType() == Lexeme.OPERATOR && op.IsBinary() == isBinary && lex.GetValue
                    ().Equals(op.GetSymbol()))
                {
                    return op;
                }
                else
                {
                    if (lex.GetType() == Lexeme.LPAREN && op.GetSymbol().Equals("("))
                    {
                        return op;
                    }
                    else
                    {
                        if (lex.GetType() == Lexeme.RPAREN && op.GetSymbol().Equals(")"))
                        {
                            return op;
                        }
                        else
                        {
                            if (lex.GetType() == Lexeme.WORD && op.GetSymbol().Equals(lex.GetValue()))
                            {
                                return op;
                            }
                            else
                            {
                                if (lex.GetType() == Lexeme.COMMA && op.GetSymbol().Equals(","))
                                {
                                    return op;
                                }
                            }
                        }
                    }
                }
            }
            throw new ExpressionParseException("Expression string cannot be tokenized at " +
                lex.ToString() + " isBinary:" + isBinary, -1);
        }
 public AtomicNode(string name, Expression child, Operator oper)
 {
     //setChild(child);
     this.@operator = oper;
     this.name = name;
 }
Ejemplo n.º 5
0
 public OpNode(Expression[] children, Operator oper)
 {
     this.@operator = oper;
     this.children = children;
 }