示例#1
0
        private IAstNode Shift(IAstNode left, int level)
        {
            AstLeaf  op    = new AstLeaf(_lexer.Read());
            IAstNode right = Factor();

            Precedence next;

            while ((next = NextOperator()) != null && RightFirst(level, next))
            {
                right = Shift(right, next.Level);
            }

            return(new ExpressionNode(new Collection <IAstNode>()
            {
                left, op, right
            }));
        }
示例#2
0
文件: Parser.cs 项目: ljcleo/LEP
        private IAstNode Shift(IAstNode left, int level)
        {
            AstLeaf op = new AstLeaf(_lexer.Read());
            IAstNode right = Factor();

            Precedence next;
            while ((next = NextOperator()) != null && RightFirst(level, next)) right = Shift(right, next.Level);

            return new ExpressionNode(new Collection<IAstNode>() { left, op, right });
        }