Skip to content

Commit

Permalink
Add symbols to command identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
kit494way committed Jan 11, 2024
1 parent 747cb55 commit 3f6d775
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 3f6d775

Please sign in to comment.