-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support "if" without "else" clause #1825
Conversation
I'm having troubles compiling bison 3.0.4 on my Mac, but I did manage to run the build in a fedora container with bison 3.0.5. I basically added all the changes and removed the updates to |
Looks like failures are related to bundler missing in some environments, and one failed |
src/parser.y
Outdated
@@ -357,9 +357,8 @@ Term "as" Patterns '|' Exp { | |||
"if" Exp "then" Exp ElseBody { | |||
$$ = gen_cond($2, $4, $5); | |||
} | | |||
"if" Exp "then" error { |
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 think we still want to retain an error case though, for when the end
token is missing.
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.
Good point.
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.
Fixed in latest commit. (Can squash when everything looks good)
@chancez LGTM. Please squash. Do also please update the docs (and squash that too), then I'll merge. |
1 similar comment
@chancez LGTM. Please squash. Do also please update the docs (and squash that too), then I'll merge. |
Ok, I'll try to get to that later in the week when I have some more time. |
Defaults the else clause to the identity filter "." if an else clause is missing. The following two jq programs are considered equivalent: ``` if .foo then .foo = "bar" else . end ``` ``` if .foo then .foo = "bar" end ```
34379b9
to
6c73fae
Compare
@chancez I've squash/rebased, added a commit for docs, and pushed to your branch. I'll merge shortly. |
Thanks! |
Awesome thanks! |
This implements #1824. I decided to take a stab at it to see how difficult it
was, and it wasn't so difficult. Currently this PR only contains changes to the
yacc file because my yacc is quite newer and I'm seeing a lot of extraneous
changes to the
parser.c
andparser.h
files.Defaults the else clause to the identity filter "." if an else clause is
missing.
The following two jq programs are considered equivalent:
Closes #1824