Skip to content

Commit

Permalink
Merge pull request nushell#55 from kit494way/fix-parsing-binary-expre…
Browse files Browse the repository at this point in the history
…ssion

Fix parsing of binary expression
  • Loading branch information
fdncred authored Jan 3, 2024
2 parents 169d7c7 + bc551a8 commit 06fdb75
Show file tree
Hide file tree
Showing 4 changed files with 173,411 additions and 157,986 deletions.
15 changes: 15 additions & 0 deletions corpus/expr/binary-expr.nu
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,18 @@ expr-002-preceedence
(expr_binary
(val_number)
(val_number))))))

====
expr-003-rhs-unquoted
====

'foo' == bar

----

(nu_script
(pipeline
(pipe_element
(expr_binary
(val_string)
(val_string)))))
5 changes: 4 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,10 @@ module.exports = grammar({
seq(
field("lhs", $._expression),
field("opr", opr),
field("rhs", $._expression),
field(
"rhs",
choice($._expression, alias($.unquoted, $.val_string)),
),
),
),
),
Expand Down
234 changes: 208 additions & 26 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -5525,8 +5525,22 @@
"type": "FIELD",
"name": "rhs",
"content": {
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "unquoted"
},
"named": true,
"value": "val_string"
}
]
}
}
]
Expand Down Expand Up @@ -5575,8 +5589,22 @@
"type": "FIELD",
"name": "rhs",
"content": {
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "unquoted"
},
"named": true,
"value": "val_string"
}
]
}
}
]
Expand Down Expand Up @@ -5617,8 +5645,22 @@
"type": "FIELD",
"name": "rhs",
"content": {
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "unquoted"
},
"named": true,
"value": "val_string"
}
]
}
}
]
Expand Down Expand Up @@ -5659,8 +5701,22 @@
"type": "FIELD",
"name": "rhs",
"content": {
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "unquoted"
},
"named": true,
"value": "val_string"
}
]
}
}
]
Expand Down Expand Up @@ -5717,8 +5773,22 @@
"type": "FIELD",
"name": "rhs",
"content": {
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "unquoted"
},
"named": true,
"value": "val_string"
}
]
}
}
]
Expand Down Expand Up @@ -5767,8 +5837,22 @@
"type": "FIELD",
"name": "rhs",
"content": {
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "unquoted"
},
"named": true,
"value": "val_string"
}
]
}
}
]
Expand Down Expand Up @@ -5809,8 +5893,22 @@
"type": "FIELD",
"name": "rhs",
"content": {
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "unquoted"
},
"named": true,
"value": "val_string"
}
]
}
}
]
Expand Down Expand Up @@ -5842,8 +5940,22 @@
"type": "FIELD",
"name": "rhs",
"content": {
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "unquoted"
},
"named": true,
"value": "val_string"
}
]
}
}
]
Expand Down Expand Up @@ -5875,8 +5987,22 @@
"type": "FIELD",
"name": "rhs",
"content": {
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "unquoted"
},
"named": true,
"value": "val_string"
}
]
}
}
]
Expand Down Expand Up @@ -5908,8 +6034,22 @@
"type": "FIELD",
"name": "rhs",
"content": {
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "unquoted"
},
"named": true,
"value": "val_string"
}
]
}
}
]
Expand Down Expand Up @@ -5941,8 +6081,22 @@
"type": "FIELD",
"name": "rhs",
"content": {
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "unquoted"
},
"named": true,
"value": "val_string"
}
]
}
}
]
Expand Down Expand Up @@ -5974,8 +6128,22 @@
"type": "FIELD",
"name": "rhs",
"content": {
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "unquoted"
},
"named": true,
"value": "val_string"
}
]
}
}
]
Expand Down Expand Up @@ -6007,8 +6175,22 @@
"type": "FIELD",
"name": "rhs",
"content": {
"type": "SYMBOL",
"name": "_expression"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "unquoted"
},
"named": true,
"value": "val_string"
}
]
}
}
]
Expand Down
Loading

0 comments on commit 06fdb75

Please sign in to comment.