-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating and moving the grammar to a separate file #2
base: master
Are you sure you want to change the base?
Conversation
This commit simplifies the JMESPath grammar and moved the grammar to a separate downloadable file.
a486562
to
d291d11
Compare
Actually, "||" and "|" are still ambiguous. What's the desired precedence here? I found more ambiguities with pipes and ors: I've also adding slicing and grouping to the grammar. |
I had an updated grammar somewhere that had part of the precedence baked into the grammar. It wasn't complete but it had the or/pipe's worked out. I'll see if I can find that branch. We should double check that it's consistent with this. The desired precedence is that
|
Good catch. I've pushed a commit that ensures that or expressions bind more tightly than pipe expressions. |
29a4433
to
d89729e
Compare
d89729e
to
d5d3cac
Compare
Added an "and-expression". Added a "not" expression. not and binary expressions can be at the root level. Filter expressions now support unary conditions. Simplified function argument grammar. Fixed a bug in how literals were described.
I've now shortened the majority of the rule names (e.g., I updated the I updated subexpr to now split out into I think this grammar update is pretty close to being a fully functional and non-ambiguous replacement to the current grammar. I'm using this grammar verbatim in the Clojure implementation, so you can use that and play around with how it parses to see how everything works. I'll continue to flesh out the Clojure implementation and try to get it fully compliant with the test suite to ensure that the grammar is backwards compatible. |
a9b0bd7
to
8698eb1
Compare
Renaming function-arg* to arg and arg-list
I pushed a change that allows for insignificant whitespace built into the grammar (similar to the JSON ABNF). This makes the grammar much more robust and does not require implementation details to be part of parsing (i.e., we no longer need to say "whitespace is insignificant except inside of quotes and literals). |
e782dda
to
7a82416
Compare
I'm starting to pick up work again on JEP-9 (the improved filters with ands, nots, parens, etc) and I want to incorporate this grammar as part of that work. I'm starting to take a look at this. |
wildcard-values = "*" | ||
current-node = "@" | ||
|
||
number = *"-" 1*DIGIT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't have the *
. It should just be optional instead of zero or more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, should be ["-"] 1*DIGIT
I'll send an updated PR shortly |
current-node = "@" | ||
|
||
number = *"-" 1*DIGIT | ||
literal = "`" 1*(unescaped-literal / escaped-literal) "`" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the motivation for this change? I would prefer to have the JSON grammar in here. Otherwise this will allow invalid strings such as:
`[`
which is invalid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought [
was valid (currently) because JMESPath allows you to pass in unquoted strings here. It will try to parse and see that it failed and then parse it as "["
.
Actually, I've got an updated copy of the grammar that includes JSON and fixes a bunch of stuff from the clojure implementation... Updating coming. |
Incorporates JSON back into the grammar. Much better use of insignificant whitespace. Uses `[optional]` syntax as it is clearer than `1* optional`.
I've updated the grammar to include the changes from jmespath.clj. This includes adding JSON back into the grammar and better whitespace control. |
|
||
; "&&" binds more tightly than "||" | ||
; "||" binds more tightly than "|". | ||
terminal = pipe / or / and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, why is this called terminal? I'm thinking of terminals as the leaf nodes in the parsed tree, i.e it can't be replaced with anything. But everything on the RHS can be broken down into more nodes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it isn't a good name. I named it this because it owns the entire side. Do you have a suggestion?
I've updated the grammar to support JEP 12 and added support to the Clojure implementation for raw string literals. |
; Strings, identifiers, and characters. | ||
raw-string = "'" *raw-string-char "'" | ||
raw-string-char = (%x20-26 / %x28-5B / %x5D-10FFFF) / raw-string-escape | ||
raw-string-escape = escape ["'"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a heads up, I synced with this latest version that includes raw string literals and abnfstress caught this. The ["'"]
means that the closing single quote is optional so strings such as '\'
would be valid. This should be raw-string-escape = escape "'"
This commit simplifies the JMESPath grammar and moved the grammar to a
separate downloadable file.
This is WIP PR. I'm finding other places in the grammar that I think could be improved.