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; }
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; } }
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; }