public FunctionAST(PrototypeAST proto, IExprAST body) { _proto = proto; _body = body; }
public BinaryExprAST(char op, IExprAST rhs, IExprAST lhs) { _op = op; _lhs = lhs; _rhs = rhs; }
public CallExprAST(string callee, IExprAST[] args) { _callee = callee; _args = args; }
public static IExprAST ParseBinOpRHS(int exprPrec, IExprAST lhs, Queue<Lexed> tokens) { while (true) { var tokPrec = GetTokPrecedence(tokens.Peek().Token); if (tokPrec < exprPrec) { return lhs; } var binOp = (char)tokens.Dequeue().Token; var rhs = ParsePrimary(tokens); if (rhs == null) return null; var nextPrec = GetTokPrecedence(tokens.Peek().Token); if (tokPrec < nextPrec) { rhs = ParseBinOpRHS(tokPrec + 1, rhs, tokens); if (rhs == null) return null; } lhs = new BinaryExprAST(binOp, lhs, rhs); } }