Beispiel #1
0
        ast.ExprNode ParseLtr(fnExprNode Next, ParseContext ctx, Func <Token, bool> TokenCheck)
        {
            // Parse the LHS
            var lhs = Next(ctx);

            ast.ExprNodeLtr ltr = null;

            // Parse all consecutive RHS
            while (true)
            {
                // Check operator at same precedence level
                if (TokenCheck(t.token))
                {
                    if (ltr == null)
                    {
                        ltr = new ast.ExprNodeLtr(lhs.Bookmark, lhs);
                    }

                    // Save the operator token
                    var bmk = t.GetBookmark();
                    t.Next();

                    // Parse the rhs
                    ltr.AddTerm(bmk.token, Next(ctx));
                }
                else
                {
                    return(ltr == null ? lhs : ltr);
                }
            }
        }
Beispiel #2
0
        ast.ExprNode ParseLtr(fnExprNode Next, ParseContext ctx, Func<Token, bool> TokenCheck)
        {
            // Parse the LHS
            var lhs = Next(ctx);

            ast.ExprNodeLtr ltr = null;

            // Parse all consecutive RHS
            while (true)
            {
                // Check operator at same precedence level
                if (TokenCheck(t.token))
                {
                    if (ltr == null)
                    {
                        ltr = new ast.ExprNodeLtr(lhs.Bookmark, lhs);
                    }

                    // Save the operator token
                    var bmk = t.GetBookmark();
                    t.Next();

                    // Parse the rhs
                    ltr.AddTerm(bmk.token, Next(ctx));
                }
                else
                    return ltr == null ? lhs : ltr;
            }
        }