Skip to content

Commit

Permalink
Allow # in identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
leoluk committed May 27, 2020
1 parent 2929f7e commit a003fa4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions cmd/gen-syntax/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,10 @@ const (
)

const (
identChar = `[\p{L}\p{Nd}_\$]`
identChar = `[\p{L}\p{Nd}_\$\#]`
identExported = `\p{Lu}` + identChar + `*`
identLocal = `\p{Ll}` + identChar + `*`
identNormal = `[\p{L}\$]` + identChar + `*`
identNormal = `[\p{L}\$\#]` + identChar + `*`
identHidden = `_` + identChar + `+`
identPackage = identNormal
identAny = identNormal + `|` + identHidden
Expand Down
42 changes: 21 additions & 21 deletions syntaxes/cue.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"include": "#comment"
},
{
"match": "(?<![\\p{L}\\p{Nd}_\\$])(package)[ \\t]+([\\p{L}\\$][\\p{L}\\p{Nd}_\\$]*)(?![\\p{L}\\p{Nd}_\\$])",
"match": "(?<![\\p{L}\\p{Nd}_\\$\\#])(package)[ \\t]+([\\p{L}\\$\\#][\\p{L}\\p{Nd}_\\$\\#]*)(?![\\p{L}\\p{Nd}_\\$\\#])",
"captures": {
"1": {
"name": "keyword.other.package"
Expand All @@ -23,7 +23,7 @@
{
"patterns": [
{
"begin": "(?<![\\p{L}\\p{Nd}_\\$])(import)[ \\t]+(\\()",
"begin": "(?<![\\p{L}\\p{Nd}_\\$\\#])(import)[ \\t]+(\\()",
"beginCaptures": {
"1": {
"name": "keyword.other.import"
Expand All @@ -46,7 +46,7 @@
"include": "#comment"
},
{
"match": "(?:([\\p{L}\\$][\\p{L}\\p{Nd}_\\$]*)[ \\t]+)?(\")([^:\"]+)(?:(:)([\\p{L}\\$][\\p{L}\\p{Nd}_\\$]*))?(\")",
"match": "(?:([\\p{L}\\$\\#][\\p{L}\\p{Nd}_\\$\\#]*)[ \\t]+)?(\")([^:\"]+)(?:(:)([\\p{L}\\$\\#][\\p{L}\\p{Nd}_\\$\\#]*))?(\")",
"captures": {
"1": {
"name": "entity.name.namespace"
Expand Down Expand Up @@ -80,7 +80,7 @@
"name": "meta.imports"
},
{
"match": "(?<![\\p{L}\\p{Nd}_\\$])(import)[ \\t]+(?:([\\p{L}\\$][\\p{L}\\p{Nd}_\\$]*)[ \\t]+)?(\")([^:\"]+)(?:(:)([\\p{L}\\$][\\p{L}\\p{Nd}_\\$]*))?(\")",
"match": "(?<![\\p{L}\\p{Nd}_\\$\\#])(import)[ \\t]+(?:([\\p{L}\\$\\#][\\p{L}\\p{Nd}_\\$\\#]*)[ \\t]+)?(\")([^:\"]+)(?:(:)([\\p{L}\\$\\#][\\p{L}\\p{Nd}_\\$\\#]*))?(\")",
"captures": {
"1": {
"name": "keyword.other.import"
Expand Down Expand Up @@ -122,7 +122,7 @@
"attribute_element": {
"patterns": [
{
"begin": "([\\p{L}\\$][\\p{L}\\p{Nd}_\\$]*|_[\\p{L}\\p{Nd}_\\$]+)(=)",
"begin": "([\\p{L}\\$\\#][\\p{L}\\p{Nd}_\\$\\#]*|_[\\p{L}\\p{Nd}_\\$\\#]+)(=)",
"beginCaptures": {
"1": {
"name": "variable.other"
Expand All @@ -139,7 +139,7 @@
]
},
{
"begin": "([\\p{L}\\$][\\p{L}\\p{Nd}_\\$]*|_[\\p{L}\\p{Nd}_\\$]+)(\\()",
"begin": "([\\p{L}\\$\\#][\\p{L}\\p{Nd}_\\$\\#]*|_[\\p{L}\\p{Nd}_\\$\\#]+)(\\()",
"beginCaptures": {
"1": {
"name": "variable.other"
Expand Down Expand Up @@ -209,7 +209,7 @@
"declaration": {
"patterns": [
{
"begin": "(@)([\\p{L}\\$][\\p{L}\\p{Nd}_\\$]*|_[\\p{L}\\p{Nd}_\\$]+)(\\()",
"begin": "(@)([\\p{L}\\$\\#][\\p{L}\\p{Nd}_\\$\\#]*|_[\\p{L}\\p{Nd}_\\$\\#]+)(\\()",
"beginCaptures": {
"1": {
"name": "punctuation.definition.annotation"
Expand Down Expand Up @@ -266,7 +266,7 @@
{
"patterns": [
{
"match": "(?<![\\p{L}\\p{Nd}_\\$])(for)[ \\t]+([\\p{L}\\$][\\p{L}\\p{Nd}_\\$]*|_[\\p{L}\\p{Nd}_\\$]+)(?:[ \\t]*(,)[ \\t]*([\\p{L}\\$][\\p{L}\\p{Nd}_\\$]*|_[\\p{L}\\p{Nd}_\\$]+))?[ \\t]+(in)(?![\\p{L}\\p{Nd}_\\$])",
"match": "(?<![\\p{L}\\p{Nd}_\\$\\#])(for)[ \\t]+([\\p{L}\\$\\#][\\p{L}\\p{Nd}_\\$\\#]*|_[\\p{L}\\p{Nd}_\\$\\#]+)(?:[ \\t]*(,)[ \\t]*([\\p{L}\\$\\#][\\p{L}\\p{Nd}_\\$\\#]*|_[\\p{L}\\p{Nd}_\\$\\#]+))?[ \\t]+(in)(?![\\p{L}\\p{Nd}_\\$\\#])",
"captures": {
"1": {
"name": "keyword.control.for"
Expand All @@ -286,11 +286,11 @@
}
},
{
"match": "(?<![\\p{L}\\p{Nd}_\\$])if(?![\\p{L}\\p{Nd}_\\$])",
"match": "(?<![\\p{L}\\p{Nd}_\\$\\#])if(?![\\p{L}\\p{Nd}_\\$\\#])",
"name": "keyword.control.conditional"
},
{
"match": "(?<![\\p{L}\\p{Nd}_\\$])(let)[ \\t]+([\\p{L}\\$][\\p{L}\\p{Nd}_\\$]*|_[\\p{L}\\p{Nd}_\\$]+)[ \\t]*(=)(?![=])",
"match": "(?<![\\p{L}\\p{Nd}_\\$\\#])(let)[ \\t]+([\\p{L}\\$\\#][\\p{L}\\p{Nd}_\\$\\#]*|_[\\p{L}\\p{Nd}_\\$\\#]+)[ \\t]*(=)(?![=])",
"captures": {
"1": {
"name": "keyword.control.let"
Expand All @@ -312,7 +312,7 @@
"name": "keyword.operator"
},
{
"match": "(?<![\\p{L}\\p{Nd}_\\$])(?:div|mod|quo|rem)(?![\\p{L}\\p{Nd}_\\$])",
"match": "(?<![\\p{L}\\p{Nd}_\\$\\#])(?:div|mod|quo|rem)(?![\\p{L}\\p{Nd}_\\$\\#])",
"name": "keyword.operator.word"
},
{
Expand All @@ -330,7 +330,7 @@
]
},
{
"match": "(?<!\\.)(\\.)([\\p{L}\\$][\\p{L}\\p{Nd}_\\$]*|_[\\p{L}\\p{Nd}_\\$]+)(?![\\p{L}\\p{Nd}_\\$])",
"match": "(?<!\\.)(\\.)([\\p{L}\\$\\#][\\p{L}\\p{Nd}_\\$\\#]*|_[\\p{L}\\p{Nd}_\\$\\#]+)(?![\\p{L}\\p{Nd}_\\$\\#])",
"captures": {
"1": {
"name": "punctuation.accessor"
Expand All @@ -343,19 +343,19 @@
{
"patterns": [
{
"match": "(?<![\\p{L}\\p{Nd}_\\$])_(?!\\|)(?![\\p{L}\\p{Nd}_\\$])",
"match": "(?<![\\p{L}\\p{Nd}_\\$\\#])_(?!\\|)(?![\\p{L}\\p{Nd}_\\$\\#])",
"name": "constant.language.top"
},
{
"match": "(?<![\\p{L}\\p{Nd}_\\$])_\\|_(?![\\p{L}\\p{Nd}_\\$])",
"match": "(?<![\\p{L}\\p{Nd}_\\$\\#])_\\|_(?![\\p{L}\\p{Nd}_\\$\\#])",
"name": "constant.language.bottom"
},
{
"match": "(?<![\\p{L}\\p{Nd}_\\$])null(?![\\p{L}\\p{Nd}_\\$])",
"match": "(?<![\\p{L}\\p{Nd}_\\$\\#])null(?![\\p{L}\\p{Nd}_\\$\\#])",
"name": "constant.language.null"
},
{
"match": "(?<![\\p{L}\\p{Nd}_\\$])(?:true|false)(?![\\p{L}\\p{Nd}_\\$])",
"match": "(?<![\\p{L}\\p{Nd}_\\$\\#])(?:true|false)(?![\\p{L}\\p{Nd}_\\$\\#])",
"name": "constant.language.bool"
},
{
Expand Down Expand Up @@ -414,13 +414,13 @@
"include": "#string"
},
{
"match": "(?<![\\p{L}\\p{Nd}_\\$])(?:bool|u?int(?:8|16|32|64|128)?|float(?:32|64)?|string|bytes|number|rune)(?![\\p{L}\\p{Nd}_\\$])",
"match": "(?<![\\p{L}\\p{Nd}_\\$\\#])(?:bool|u?int(?:8|16|32|64|128)?|float(?:32|64)?|string|bytes|number|rune)(?![\\p{L}\\p{Nd}_\\$\\#])",
"name": "support.type"
},
{
"patterns": [
{
"begin": "(?<![\\p{L}\\p{Nd}_\\$])(len|close|and|or)(\\()",
"begin": "(?<![\\p{L}\\p{Nd}_\\$\\#])(len|close|and|or)(\\()",
"beginCaptures": {
"1": {
"name": "support.function"
Expand Down Expand Up @@ -455,7 +455,7 @@
"name": "meta.function-call"
},
{
"begin": "(?<![\\p{L}\\p{Nd}_\\$])([\\p{L}\\$][\\p{L}\\p{Nd}_\\$]*)(\\.)(\\p{Lu}[\\p{L}\\p{Nd}_\\$]*)(\\()",
"begin": "(?<![\\p{L}\\p{Nd}_\\$\\#])([\\p{L}\\$\\#][\\p{L}\\p{Nd}_\\$\\#]*)(\\.)(\\p{Lu}[\\p{L}\\p{Nd}_\\$\\#]*)(\\()",
"beginCaptures": {
"1": {
"name": "support.module"
Expand Down Expand Up @@ -498,7 +498,7 @@
]
},
{
"match": "(?<![\\p{L}\\p{Nd}_\\$])(?:[\\p{L}\\$][\\p{L}\\p{Nd}_\\$]*|_[\\p{L}\\p{Nd}_\\$]+)(?![\\p{L}\\p{Nd}_\\$])",
"match": "(?<![\\p{L}\\p{Nd}_\\$\\#])(?:[\\p{L}\\$\\#][\\p{L}\\p{Nd}_\\$\\#]*|_[\\p{L}\\p{Nd}_\\$\\#]+)(?![\\p{L}\\p{Nd}_\\$\\#])",
"name": "variable.other"
},
{
Expand Down Expand Up @@ -566,7 +566,7 @@
"include": "#punctuation_ellipsis"
},
{
"match": "([\\p{L}\\$][\\p{L}\\p{Nd}_\\$]*|_[\\p{L}\\p{Nd}_\\$]+)[ \\t]*(=)",
"match": "([\\p{L}\\$\\#][\\p{L}\\p{Nd}_\\$\\#]*|_[\\p{L}\\p{Nd}_\\$\\#]+)[ \\t]*(=)",
"captures": {
"1": {
"name": "variable.other"
Expand Down

0 comments on commit a003fa4

Please sign in to comment.