private JmespathExpression led()

in smithy-jmespath/src/main/java/software/amazon/smithy/jmespath/Parser.java [149:200]


    private JmespathExpression led(JmespathExpression left) {
        Token token = iterator.expect(LED_TOKENS);

        switch (token.type) {
            case DOT:
                // For example, "foo.bar"
                if (iterator.peek().type == TokenType.STAR) {
                    // "Example: foo.*". This is mostly an optimization of the
                    // generated AST to not need a subexpression to contain the
                    // projection.
                    iterator.expect(TokenType.STAR); // skip the "*".
                    return parseWildcardObject(left);
                } else {
                    // "foo.*", "foo.bar", "foo.[bar]", "foo.length(@)", etc.
                    JmespathExpression dotRhs = parseDotRhs(TokenType.DOT.lbp);
                    return new Subexpression(left, dotRhs, token.line, token.column);
                }
            case FLATTEN: // Example: a[].b
                return parseFlatten(left);
            case OR: // Example: a || b
                return new OrExpression(left, expression(token.type.lbp), token.line, token.column);
            case AND: // Example: a && b
                return new AndExpression(left, expression(token.type.lbp), token.line, token.column);
            case PIPE: // Example: a | b
                return new Subexpression(left, expression(token.type.lbp), token.line, token.column, true);
            case FILTER: // Example: a[?foo == bar]
                return parseFilter(left);
            case LBRACKET:
                Token bracketToken = iterator.expectPeek(TokenType.NUMBER, TokenType.COLON, TokenType.STAR);
                if (bracketToken.type == TokenType.STAR) {
                    // For example, "foo[*]"
                    return parseWildcardIndex(left);
                } else {
                    // For example, "foo[::1]", "foo[1]"
                    return new Subexpression(left, parseIndex(), token.line, token.column);
                }
            case EQUAL: // Example: a == b
                return parseComparator(ComparatorType.EQUAL, left);
            case NOT_EQUAL: // Example: a != b
                return parseComparator(ComparatorType.NOT_EQUAL, left);
            case GREATER_THAN: // Example: a > b
                return parseComparator(ComparatorType.GREATER_THAN, left);
            case GREATER_THAN_EQUAL: // Example: a >= b
                return parseComparator(ComparatorType.GREATER_THAN_EQUAL, left);
            case LESS_THAN: // Example: a < b
                return parseComparator(ComparatorType.LESS_THAN, left);
            case LESS_THAN_EQUAL: // Example: a <= b
                return parseComparator(ComparatorType.LESS_THAN_EQUAL, left);
            default:
                throw iterator.syntax("Invalid led token: " + token);
        }
    }