Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 protected void RegisterParselet(TokenType tokenType, InfixParselet parselet)
 {
     _infixParselets.Add(tokenType, parselet);
 }