private void GetNext() { SkipWhitespace(); char ch = GetNextChar(); if (Char.IsDigit(ch)) { StringBuilder str = new StringBuilder(); while (Char.IsDigit(ch)) { str.Append(ch); ch = GetNextChar(); } index--; try { constant = op.Parse(str.ToString()); } catch { throw new OverflowException(); } current = State.number; } else if (ch == '+') { current = State.plus; } else if (ch == '-') { if (expression.Length >= index + 10 && expression.Substring(index, index + 10).Equals("2147483648")) { constant = op.Parse(expression.Substring(index - 1, index + 10)); index += 10; current = State.number; } else { current = State.minus; } } else if (ch == '*') { current = State.asterisk; } else if (ch == '/') { current = State.slash; } else if (ch == '(') { current = State.lparen; } else if (ch == ')') { current = State.rparen; } else if (ch == 'x' || ch == 'y' || ch == 'z') { current = State.variable; variable = ch; } else { if (expression.Length >= index + 2 && expression.Substring(index - 1, index + 2).Equals("abs")) { index += 2; current = State.abs; } else if (expression.Length >= index + 5 && expression.Substring(index - 1, index + 5).Equals("square")) { index += 5; current = State.square; } else if (expression.Length >= index + 2 && expression.Substring(index - 1, index + 2).Equals("mod")) { index += 2; current = State.mod; } else if (!Char.IsWhiteSpace(ch)) { throw new ParsingException("unexpected char: \"" + ch + "\" at index: " + (index - 1)); } } SkipWhitespace(); }