---------- Input ----------
$
---------- Output ---------
$
---------- AST ------------
JsonPath {
    paths: [
        Root,
    ],
}


---------- Input ----------
$.*
---------- Output ---------
$.*
---------- AST ------------
JsonPath {
    paths: [
        Root,
        DotWildcard,
    ],
}


---------- Input ----------
$[*]
---------- Output ---------
$[*]
---------- AST ------------
JsonPath {
    paths: [
        Root,
        BracketWildcard,
    ],
}


---------- Input ----------
$.store.book[*].*
---------- Output ---------
$.store.book[*].*
---------- AST ------------
JsonPath {
    paths: [
        Root,
        DotField(
            "store",
        ),
        DotField(
            "book",
        ),
        BracketWildcard,
        DotWildcard,
    ],
}


---------- Input ----------
$.store.book[0].price
---------- Output ---------
$.store.book[0].price
---------- AST ------------
JsonPath {
    paths: [
        Root,
        DotField(
            "store",
        ),
        DotField(
            "book",
        ),
        ArrayIndices(
            [
                Index(
                    Index(
                        0,
                    ),
                ),
            ],
        ),
        DotField(
            "price",
        ),
    ],
}


---------- Input ----------
$.store.book[last].isbn
---------- Output ---------
$.store.book[last].isbn
---------- AST ------------
JsonPath {
    paths: [
        Root,
        DotField(
            "store",
        ),
        DotField(
            "book",
        ),
        ArrayIndices(
            [
                Index(
                    LastIndex(
                        0,
                    ),
                ),
            ],
        ),
        DotField(
            "isbn",
        ),
    ],
}


---------- Input ----------
$.store.book[0,1, last - 2].price
---------- Output ---------
$.store.book[0, 1, last-2].price
---------- AST ------------
JsonPath {
    paths: [
        Root,
        DotField(
            "store",
        ),
        DotField(
            "book",
        ),
        ArrayIndices(
            [
                Index(
                    Index(
                        0,
                    ),
                ),
                Index(
                    Index(
                        1,
                    ),
                ),
                Index(
                    LastIndex(
                        -2,
                    ),
                ),
            ],
        ),
        DotField(
            "price",
        ),
    ],
}


---------- Input ----------
$.store.book[0,1 to last-1]
---------- Output ---------
$.store.book[0, 1 to last-1]
---------- AST ------------
JsonPath {
    paths: [
        Root,
        DotField(
            "store",
        ),
        DotField(
            "book",
        ),
        ArrayIndices(
            [
                Index(
                    Index(
                        0,
                    ),
                ),
                Slice(
                    (
                        Index(
                            1,
                        ),
                        LastIndex(
                            -1,
                        ),
                    ),
                ),
            ],
        ),
    ],
}


---------- Input ----------
$."store"."book"
---------- Output ---------
$.store.book
---------- AST ------------
JsonPath {
    paths: [
        Root,
        DotField(
            "store",
        ),
        DotField(
            "book",
        ),
    ],
}


---------- Input ----------
$[*].book.price ? (@ == 10)
---------- Output ---------
$[*].book.price?(@ == 10)
---------- AST ------------
JsonPath {
    paths: [
        Root,
        BracketWildcard,
        DotField(
            "book",
        ),
        DotField(
            "price",
        ),
        FilterExpr(
            BinaryOp {
                op: Eq,
                left: Paths(
                    [
                        Current,
                    ],
                ),
                right: Value(
                    Number(
                        UInt64(
                            10,
                        ),
                    ),
                ),
            },
        ),
    ],
}


---------- Input ----------
$.store.book?(@.price > 10).title
---------- Output ---------
$.store.book?(@.price > 10).title
---------- AST ------------
JsonPath {
    paths: [
        Root,
        DotField(
            "store",
        ),
        DotField(
            "book",
        ),
        FilterExpr(
            BinaryOp {
                op: Gt,
                left: Paths(
                    [
                        Current,
                        DotField(
                            "price",
                        ),
                    ],
                ),
                right: Value(
                    Number(
                        UInt64(
                            10,
                        ),
                    ),
                ),
            },
        ),
        DotField(
            "title",
        ),
    ],
}


---------- Input ----------
$.store.book?(@.price < $.expensive).price
---------- Output ---------
$.store.book?(@.price < $.expensive).price
---------- AST ------------
JsonPath {
    paths: [
        Root,
        DotField(
            "store",
        ),
        DotField(
            "book",
        ),
        FilterExpr(
            BinaryOp {
                op: Lt,
                left: Paths(
                    [
                        Current,
                        DotField(
                            "price",
                        ),
                    ],
                ),
                right: Paths(
                    [
                        Root,
                        DotField(
                            "expensive",
                        ),
                    ],
                ),
            },
        ),
        DotField(
            "price",
        ),
    ],
}


---------- Input ----------
$.store.book?(@.price < 10 && @.category == "fiction")
---------- Output ---------
$.store.book?(@.price < 10 && @.category == "fiction")
---------- AST ------------
JsonPath {
    paths: [
        Root,
        DotField(
            "store",
        ),
        DotField(
            "book",
        ),
        FilterExpr(
            BinaryOp {
                op: And,
                left: BinaryOp {
                    op: Lt,
                    left: Paths(
                        [
                            Current,
                            DotField(
                                "price",
                            ),
                        ],
                    ),
                    right: Value(
                        Number(
                            UInt64(
                                10,
                            ),
                        ),
                    ),
                },
                right: BinaryOp {
                    op: Eq,
                    left: Paths(
                        [
                            Current,
                            DotField(
                                "category",
                            ),
                        ],
                    ),
                    right: Value(
                        String(
                            "fiction",
                        ),
                    ),
                },
            },
        ),
    ],
}


---------- Input ----------
$.store.book?(@.price > 10 || @.category == "reference")
---------- Output ---------
$.store.book?(@.price > 10 || @.category == "reference")
---------- AST ------------
JsonPath {
    paths: [
        Root,
        DotField(
            "store",
        ),
        DotField(
            "book",
        ),
        FilterExpr(
            BinaryOp {
                op: Or,
                left: BinaryOp {
                    op: Gt,
                    left: Paths(
                        [
                            Current,
                            DotField(
                                "price",
                            ),
                        ],
                    ),
                    right: Value(
                        Number(
                            UInt64(
                                10,
                            ),
                        ),
                    ),
                },
                right: BinaryOp {
                    op: Eq,
                    left: Paths(
                        [
                            Current,
                            DotField(
                                "category",
                            ),
                        ],
                    ),
                    right: Value(
                        String(
                            "reference",
                        ),
                    ),
                },
            },
        ),
    ],
}


---------- Input ----------
$.store.book?(@.price > 20 && (@.category == "reference" || @.category == "fiction"))
---------- Output ---------
$.store.book?(@.price > 20 && (@.category == "reference" || @.category == "fiction"))
---------- AST ------------
JsonPath {
    paths: [
        Root,
        DotField(
            "store",
        ),
        DotField(
            "book",
        ),
        FilterExpr(
            BinaryOp {
                op: And,
                left: BinaryOp {
                    op: Gt,
                    left: Paths(
                        [
                            Current,
                            DotField(
                                "price",
                            ),
                        ],
                    ),
                    right: Value(
                        Number(
                            UInt64(
                                20,
                            ),
                        ),
                    ),
                },
                right: BinaryOp {
                    op: Or,
                    left: BinaryOp {
                        op: Eq,
                        left: Paths(
                            [
                                Current,
                                DotField(
                                    "category",
                                ),
                            ],
                        ),
                        right: Value(
                            String(
                                "reference",
                            ),
                        ),
                    },
                    right: BinaryOp {
                        op: Eq,
                        left: Paths(
                            [
                                Current,
                                DotField(
                                    "category",
                                ),
                            ],
                        ),
                        right: Value(
                            String(
                                "fiction",
                            ),
                        ),
                    },
                },
            },
        ),
    ],
}


---------- Input ----------
[1][2]
---------- Output ---------
[1][2]
---------- AST ------------
JsonPath {
    paths: [
        ArrayIndices(
            [
                Index(
                    Index(
                        1,
                    ),
                ),
            ],
        ),
        ArrayIndices(
            [
                Index(
                    Index(
                        2,
                    ),
                ),
            ],
        ),
    ],
}


---------- Input ----------
["k1"]["k2"]
---------- Output ---------
["k1"]["k2"]
---------- AST ------------
JsonPath {
    paths: [
        ObjectField(
            "k1",
        ),
        ObjectField(
            "k2",
        ),
    ],
}


---------- Input ----------
k1.k2:k3
---------- Output ---------
.k1.k2:k3
---------- AST ------------
JsonPath {
    paths: [
        DotField(
            "k1",
        ),
        DotField(
            "k2",
        ),
        ColonField(
            "k3",
        ),
    ],
}


---------- Input ----------
k1["k2"][1]
---------- Output ---------
.k1["k2"][1]
---------- AST ------------
JsonPath {
    paths: [
        DotField(
            "k1",
        ),
        ObjectField(
            "k2",
        ),
        ArrayIndices(
            [
                Index(
                    Index(
                        1,
                    ),
                ),
            ],
        ),
    ],
}


