示例#1
0
        internal TokenBase(int lbp)
        {
            this.LBP = lbp;

            this.Nud = NudError;
            this.Led = LedError;
        }
示例#2
0
        private void RegisterToken(Int32 leftBindingPower, Func <Int32, Expression, Expression> leftDenotation, params TokenType[] tokens)
        {
            var denotation = new LeftDenotation(leftBindingPower, leftDenotation);

            foreach (TokenType tokenType in tokens)
            {
                _leftDenotations.Add(tokenType, denotation);
            }
        }
示例#3
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);
        }