private AExpression CalcTerm() { var result = CalcFactor(); while (CurrentChar() == '+' || CurrentChar() == '-') { char curChar = CurrentChar(); NextChar(); AExpression right = CalcFactor(); result = new Expression(curChar, result, right); } return(result); }
private AExpression CalcFactor() { var result = ParsePrimary(); while (CurrentChar() == '/' || CurrentChar() == '*') { char curChar = CurrentChar(); NextChar(); AExpression right = ParsePrimary(); result = new Expression(curChar, result, right); } return(result); }
private AExpression ParsePrimary() { AExpression result = null; if (IsDigit(CurrentChar())) { result = ParseInteger(); } else if (CurrentChar() == '(') { NextChar(); result = CalcAll(); SkipNextChar(); } else { Console.WriteLine("Error: unexpected symbol " + CurrentChar() + " at " + cursor); } return(result); }
public Expression(char oper, AExpression result, AExpression right2) { op = oper; left = result; right = right2; }