Skip to content
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

Add symbols to command identifier #66

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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