internal Expression parseExpression(int precedence) { Token token = consume(); PrefixParselet prefix = null; var type = token.getType(); if (!prefixParselets.TryGetValue(type, out prefix)) { throw new Exception("Could not parse \"" + token.Text + "\"."); } Expression left = prefix.parse(this, token); while (precedence < getPrecedence()) { token = consume(); InfixParselet infix = infixParselets[token.getType()]; left = infix.parse(this, left, token); } return(left); }
protected void RegisterParselet(TokenType tokenType, InfixParselet parselet) { _infixParselets.Add(tokenType, parselet); }