Beispiel #1
0
 public static Expr ParseExpression(Tokenizer Tokenizer, int rbp)
 {
     Token t = Tokenizer.Current;
     Tokenizer.Advance();
     Expr left = t.Nud();
     while (rbp > Tokenizer.Current.Lbp)
     {
         t = Tokenizer.Current;
         Tokenizer.Advance();
         left = t.Led(left);
     }
     return left;
 }
Beispiel #2
0
 public static Stmt ParseStatement(Tokenizer Tokenizer)
 {
     Stmt s;
     if (Tokenizer.Current.Std(out s))
     {
         return s;
     }
     else
     {
         SimpleToken token = Tokenizer.Current;
         Expr e = ParseExpression(Tokenizer, 13);
         s = new ExprStmt(token, Tokenizer.Current.LineNumber, e);
         Tokenizer.Advance("(eol)");
         return s;
     }
 }
Beispiel #3
0
 public static ArrayList ParseArgumentList(Tokenizer Tokenizer)
 {
     ArrayList argList = new ArrayList();
     if (Tokenizer.Current.Text != "(")
         return argList;
     Tokenizer.Advance("(");
     while (true)
     {
         argList.Add(ParseExpression(Tokenizer, 13));
         if (Tokenizer.Current.Text != ",")
             break;
         Tokenizer.Advance(",");
     }
     Tokenizer.Advance(")");
     return argList;
 }