Skip to content

Commit

Permalink
Merge pull request #80 from kit494way/fix-null
Browse files Browse the repository at this point in the history
Fix parsing of null
  • Loading branch information
fdncred authored Feb 5, 2024
2 parents 358c4f5 + 6e8ebb6 commit d0210a0
Show file tree
Hide file tree
Showing 6 changed files with 212,508 additions and 207,689 deletions.
9 changes: 7 additions & 2 deletions corpus/expr/values.nu
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,19 @@ values-002-booleans
values-003-nothing
=====

null
[
null
()
]

-----

(nu_script
(pipeline
(pipe_element
(val_nothing))))
(val_list
(val_nothing)
(val_nothing)))))

=====
values-004-binary
Expand Down
8 changes: 6 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,11 @@ module.exports = grammar({
),

/// Literals
val_nothing: ($) => SPECIAL().null,
val_nothing: ($) =>
choice(
SPECIAL().null,
seq(token(BRACK().open_paren), token.immediate(BRACK().close_paren)),
),

val_bool: ($) => choice(SPECIAL().true, SPECIAL().false),

Expand All @@ -871,7 +875,7 @@ module.exports = grammar({
_var: ($) =>
seq(
PUNC().dollar,
field("name", choice("nu", "in", "env", "nothing", $.identifier)),
field("name", choice("nu", "in", "env", $.identifier)),
),

val_number: ($) => $._val_number,
Expand Down
1 change: 0 additions & 1 deletion queries/nu/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@
"in"
"nu"
"env"
"nothing"
] @special
)
;;; ---
Expand Down
32 changes: 26 additions & 6 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -7994,8 +7994,32 @@
]
},
"val_nothing": {
"type": "STRING",
"value": "null"
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "null"
},
{
"type": "SEQ",
"members": [
{
"type": "TOKEN",
"content": {
"type": "STRING",
"value": "("
}
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": ")"
}
}
]
}
]
},
"val_bool": {
"type": "CHOICE",
Expand Down Expand Up @@ -8057,10 +8081,6 @@
"type": "STRING",
"value": "env"
},
{
"type": "STRING",
"value": "nothing"
},
{
"type": "SYMBOL",
"name": "identifier"
Expand Down
17 changes: 9 additions & 8 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -4652,6 +4652,11 @@
]
}
},
{
"type": "val_nothing",
"named": true,
"fields": {}
},
{
"type": "val_number",
"named": true,
Expand Down Expand Up @@ -4818,10 +4823,6 @@
"type": "in",
"named": false
},
{
"type": "nothing",
"named": false
},
{
"type": "nu",
"named": false
Expand Down Expand Up @@ -5925,6 +5926,10 @@
"type": "nu",
"named": false
},
{
"type": "null",
"named": false
},
{
"type": "number",
"named": false
Expand Down Expand Up @@ -6081,10 +6086,6 @@
"type": "val_date",
"named": true
},
{
"type": "val_nothing",
"named": true
},
{
"type": "var-with-opt-type",
"named": false
Expand Down
Loading

0 comments on commit d0210a0

Please sign in to comment.