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); }