public override IToken TakeToken(Position pos) { if (Check(pos)) { Position start = new Position(pos); Utills.MoveWhile(pos, varPr); string strToken = Position.CreateString(start, pos); // Specificate indentificator if (FunctionCheck(strToken)) { return(new FuncNameToken(strToken)); } else if (ConstantCheck(strToken)) { return(new ConstantToken(strToken)); } else { return(new VariableToken(strToken)); } } else { Exception ex = new Exception("Cannot take the token"); ex.Source = "IdentifierReader"; throw ex; } }
public override void Visit(IBinaryOpToken t) { // Get operators with lower or equal priority List <IToken> lowOperators = Utills.MoveWhile(t, m_operators, m_priorityPr); // Add operators to the result(RPN) list m_resultTokens.AddRange(lowOperators); m_operators.Push(t); }
public override IToken TakeToken(Position pos) { if (Check(pos)) { Position start = new Position(pos); // Main part of the number Utills.MoveWhile(pos, digitPr); // Fraction part of the number Utills.MoveWhile(pos, numSeparatorPr); Utills.MoveWhile(pos, digitPr); return(new NumberToken(Position.CreateString(start, pos))); } else { Exception ex = new Exception("Cannot take the token"); ex.Source = "NumberReader"; throw ex; } }