WHITESPACE = _{ " " }

groups = _{ selection ~ ("," ~ selection)* }
    selection = { (spread? ~ root? ~ (selector ~ ("."? ~ selector)*)?)? ~ filters* ~ truncate?}
        root = { "." }

        spread = { ".." }

        selector = _{ array | object | default }
            array = _{ "[" ~ (range | index) ~ "]" }
                range = { start? ~ ":" ~ end? }
                index = { number? ~ ("," ~ number)* }
                    number = { ASCII_DIGIT+ }
                    start = { number }
                    end = { number}
            object = _{ "{" ~ property ~ "}" }
                property = { default ~ ("," ~ default)* }
            default = ${ quote ~ chars ~ quote }
                chars = { char* }
                    char = _{
                        !("\"" | "\\") ~ ANY
                        | "\\" ~ ("\"" | "\\" | "/" | "b" | "f" | "n" | "r" | "t")
                        | "\\" ~ ("u" ~ ASCII_HEX_DIGIT{4})
                    }
                quote = { "\"" }

        filters = _{ pipe ~ filter ~ ("."? ~ filter)* }
            pipe = _{ "|" }
            filter = _{ filter_array | filter_object | filter_default }
                filter_array = _{ "[" ~ (filter_range | filter_index) ~ "]" }
                    filter_range = { range }
                    filter_index = { index }
                filter_default = { default }
                filter_object = _{ "{" ~ filter_property ~ "}" }
                    filter_property = { default ~ ("," ~ default)* }

        truncate = { "!" }