Example #1
0
 public FunctionAST(PrototypeAST proto, IExprAST body)
 {
     _proto = proto;
     _body = body;
 }
Example #2
0
 public BinaryExprAST(char op, IExprAST rhs, IExprAST lhs)
 {
     _op = op;
     _lhs = lhs;
     _rhs = rhs;
 }
Example #3
0
 public CallExprAST(string callee, IExprAST[] args)
 {
     _callee = callee;
     _args = args;
 }
Example #4
0
 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);
     }
 }