Example #1
0
 private Limit LimitStep()
 {
     Limit limit = new Limit();
     do
     {
         if (!(_curToken.Type == TokenType.Sing ||
                 _curToken.Type == TokenType.Var ||
                 _curToken.Type == TokenType.Number ||
                 _curToken.Type == TokenType.OpBr))
             throw new ParseErrorException("Не верное описание слагаемого");
         int koef = 1;
         Fraction koefVar = 1;
         if (_curToken.Type == TokenType.Sing)
         {
             if (_curToken.Value == "-") koef = -1;
             Match(_curToken.Type);
         }
         if (_curToken.Type == TokenType.Number || _curToken.Type == TokenType.OpBr)
         {
             koefVar = Number();
         }
         if (_curToken.Type != TokenType.Var)
             throw new ParseErrorException("Ожидалась переменная");
         if (!_table.ContainsKey(_curToken.Value))
             throw new ParseErrorException("Переменная " + _curToken.Value + " не объявленная");
         if (_table[_curToken.Value] == 0)
             throw new ParseErrorException("Ключевое слово " + _curToken.Value + " не может использоваться, как переменная");
         limit.addVar(koef * koefVar, _table[_curToken.Value], _curToken.Value);
         Match(_curToken.Type);
     } while (_curToken.Type != TokenType.Eq);
     if (_curToken.Value == "=")
         limit.setSing(Sing.equality);
     else if (_curToken.Value == ">=")
         limit.setSing(Sing.moreEquality);
     else limit.setSing(Sing.lessEquality);
     Match(_curToken.Type);
     Fraction left = Number();
     limit.setLeftSide(left);
     if (_curToken.Type != TokenType.SimCol)
         throw new ParseErrorException("Ожидалась точка с зяпятой");
     Match(_curToken.Type);
     return limit;
 }