Skip to content

Commit

Permalink
Merge pull request nushell#66 from kit494way/fix-command-identifier
Browse files Browse the repository at this point in the history
Add symbols to command identifier
  • Loading branch information
fdncred authored Jan 11, 2024
2 parents 747cb55 + 3f6d775 commit 192f8f6
Show file tree
Hide file tree
Showing 4 changed files with 16,116 additions and 10,341 deletions.
14 changes: 14 additions & 0 deletions corpus/decl/def.nu
Original file line number Diff line number Diff line change
Expand Up @@ -710,3 +710,17 @@ def test [x: record<key: list<int>>]: nothing -> record<key: list<int>> {
(list_type
(flat_type))))
(block)))

======
def-031-name-special-keys
======

def a_-!? [] {}

-----

(nu_script
(decl_def
(cmd_identifier)
(parameter_bracks)
(block)))
4 changes: 2 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ module.exports = grammar({

/// Identifiers
// NOTE:
// for simplicity, i used the `rust` definition of an identifier
// for simplicity, i used the `rust` definition of an identifier and some symbols
// but in `nu` the rule is way more relaxed than this

cmd_identifier: ($) => token(/[_\p{XID_Start}][_\-\p{XID_Continue}]*/),
cmd_identifier: ($) => token(/[_\p{XID_Start}][_\-\p{XID_Continue}!?]*/),

identifier: ($) => token(/[_\p{XID_Start}][_\p{XID_Continue}]*/),

Expand Down
2 changes: 1 addition & 1 deletion src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@
"type": "TOKEN",
"content": {
"type": "PATTERN",
"value": "[_\\p{XID_Start}][_\\-\\p{XID_Continue}]*"
"value": "[_\\p{XID_Start}][_\\-\\p{XID_Continue}!?]*"
}
},
"identifier": {
Expand Down
Loading

0 comments on commit 192f8f6

Please sign in to comment.