예제 #1
0
        private void RegisterToken(Int32 leftBindingPower, Func <Int32, Expression> nullDenotation, params TokenType[] tokens)
        {
            var denotation = new NullDenotation(leftBindingPower, nullDenotation);

            foreach (TokenType tokenType in tokens)
            {
                _nullDenotations.Add(tokenType, denotation);
            }
        }
예제 #2
0
        private Expression ParseExpression(Int32 leftBindingPower)
        {
            NullDenotation nullDenotation = _nullDenotations[_lookahead.Type];
            Expression     expression     = nullDenotation.Invoke();

            LeftDenotation leftDenotation = _leftDenotations[_lookahead.Type];

            while (leftDenotation != null && leftDenotation.LeftBindingPower > leftBindingPower)
            {
                expression     = leftDenotation.Invoke(expression);
                leftDenotation = _leftDenotations[_lookahead.Type];
            }

            return(expression);
        }