Skip to content

Commit

Permalink
Fix errors in grammar syntax (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaelonSuzuka authored Oct 25, 2022
1 parent 8cef953 commit 5a67e4c
Show file tree
Hide file tree
Showing 5 changed files with 265 additions and 55 deletions.
4 changes: 0 additions & 4 deletions syntaxes/GDResource.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"version": "v0.6.0",
"scopeName": "source.gdresource",
"uuid": "e076faa2-3c52-42fa-a8e6-9a7c453c1a5b",
"information_for_contributors": [
"aster: galaster@foxmail.com"
],
"patterns": [
{
"include": "#embedded_shader"
Expand Down
49 changes: 25 additions & 24 deletions syntaxes/GDScript.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"fileTypes": [
"gd"
],
"fileTypes": ["gd"],
"scopeName": "source.gdscript",
"name": "GDScript",
"patterns": [
Expand Down Expand Up @@ -286,8 +284,11 @@
"in_keyword": {
"patterns": [
{
"match": "\\b(?<=for\\s[\\w]*\\s)(in)\\b",
"name": "keyword.control.gdscript"
"match": "\\b(for)\\s+[a-zA-Z_]\\w*\\s+(in)\\b",
"captures": {
"1": { "name": "keyword.control.gdscript" },
"2": { "name": "keyword.control.gdscript" }
}
},
{
"match": "\\bin\\b",
Expand Down Expand Up @@ -356,7 +357,7 @@
},
"patterns": [
{
"match": "(:)\\s*([\\w]*)?",
"match": "(:)\\s*([a-zA-Z_]\\w*)?",
"captures": {
"1": {
"name": "punctuation.separator.annotation.gdscript"
Expand All @@ -371,7 +372,7 @@
"name": "keyword.operator.assignment.gdscript"
},
{
"match": "(setget)\\s+([\\w]*)(?:[,]\\s*([\\w]*))?",
"match": "(setget)\\s+([a-zA-Z_]\\w*)(?:[,]\\s*([a-zA-Z_]\\w*))?",
"captures": {
"1": {
"name": "storage.type.const.gdscript"
Expand Down Expand Up @@ -416,7 +417,7 @@
"include": "#line_continuation"
},
{
"match": "\\s*(\\-\\>)\\s*([a-zA-Z_][a-zA-Z_0-9]*)\\s*\\:",
"match": "\\s*(\\-\\>)\\s*([a-zA-Z_]\\w*)\\s*\\:",
"captures": {
"1": {},
"2": {
Expand Down Expand Up @@ -448,7 +449,7 @@
"name": "storage.type.new.gdscript"
}
},
"match": "\\b([a-zA-Z_][a-zA-Z_0-9]*).(new)\\("
"match": "\\b([a-zA-Z_]\\w*).(new)\\("
},
"class_is": {
"captures": {
Expand All @@ -459,7 +460,7 @@
"name": "entity.name.type.class.gdscript"
}
},
"match": "\\s+(is)\\s+([a-zA-Z_][a-zA-Z_0-9]*)"
"match": "\\s+(is)\\s+([a-zA-Z_]\\w*)"
},
"class_enum": {
"captures": {
Expand All @@ -481,10 +482,10 @@
"name": "class.other.gdscript"
}
},
"match": "(?<=class_name)\\s+([a-zA-Z_][a-zA-Z_0-9]*(\\.([a-zA-Z_][a-zA-Z_0-9]*))?)"
"match": "(?<=class_name)\\s+([a-zA-Z_]\\w*(\\.([a-zA-Z_]\\w*))?)"
},
"extends": {
"match": "(?<=extends)\\s+[a-zA-Z_][a-zA-Z_0-9]*(\\.([a-zA-Z_][a-zA-Z_0-9]*))?",
"match": "(?<=extends)\\s+[a-zA-Z_]\\w*(\\.([a-zA-Z_]\\w*))?",
"name": "entity.other.inherited-class.gdscript"
},
"builtin_func": {
Expand Down Expand Up @@ -540,11 +541,11 @@
},
"patterns": [
{
"match": "[a-zA-Z_][a-zA-Z_0-9]*/?",
"match": "[a-zA-Z_]\\w*/?",
"name": "constant.character.escape"
},
{
"match": "%[a-zA-Z_][a-zA-Z_0-9]*/?",
"match": "%[a-zA-Z_]\\w*/?",
"name": "invalid.illegal.escape.gdscript"
}
]
Expand Down Expand Up @@ -573,7 +574,7 @@
"name": "support.class.library.gdscript"
},
"signal_declaration_bare": {
"match": "(?x) \\s*\n (signal) \\s+\n ([a-zA-Z_][a-zA-Z_0-9]*)(?=[\\n\\s])",
"match": "(?x) \\s*\n (signal) \\s+\n ([a-zA-Z_]\\w*)(?=[\\n\\s])",
"captures": {
"1": {
"name": "storage.type.function.gdscript"
Expand All @@ -585,7 +586,7 @@
},
"signal_declaration": {
"name": "meta.signal.gdscript",
"begin": "(?x) \\s*\n (signal) \\s+\n ([a-zA-Z_][a-zA-Z_0-9]*) \\s*\n (?=\\()",
"begin": "(?x) \\s*\n (signal) \\s+\n ([a-zA-Z_]\\w*) \\s*\n (?=\\()",
"end": "((?=[#'\"\\n]))",
"beginCaptures": {
"1": {
Expand All @@ -603,7 +604,7 @@
"include": "#line_continuation"
},
{
"match": "\\s*(\\-\\>)\\s*([a-zA-Z_][a-zA-Z_0-9]*)\\s*\\:",
"match": "\\s*(\\-\\>)\\s*([a-zA-Z_]\\w*)\\s*\\:",
"captures": {
"1": {},
"2": {
Expand Down Expand Up @@ -636,7 +637,7 @@
},
"function_declaration": {
"name": "meta.function.gdscript",
"begin": "(?x) \\s*\n (func) \\s+\n ([a-zA-Z_][a-zA-Z_0-9]*) \\s*\n (?=\\()",
"begin": "(?x) \\s*\n (func) \\s+\n ([a-zA-Z_]\\w*) \\s*\n (?=\\()",
"end": "((:)|(?=[#'\"\\n]))",
"beginCaptures": {
"1": {
Expand All @@ -659,7 +660,7 @@
"include": "#line_continuation"
},
{
"match": "\\s*(\\-\\>)\\s*([a-zA-Z_][a-zA-Z_0-9]*)\\s*\\:",
"match": "\\s*(\\-\\>)\\s*([a-zA-Z_]\\w*)\\s*\\:",
"captures": {
"1": {},
"2": {
Expand Down Expand Up @@ -692,7 +693,7 @@
"include": "#annotated_parameter"
},
{
"match": "(?x)\n ([[:alpha:]_]\\w*)\n \\s* (?: (,) | (?=[)#\\n=]))\n",
"match": "(?x)\n ([a-zA-Z_]\\w*)\n \\s* (?: (,) | (?=[)#\\n=]))\n",
"captures": {
"1": {
"name": "variable.parameter.function.language.gdscript"
Expand Down Expand Up @@ -730,7 +731,7 @@
]
},
"annotated_parameter": {
"begin": "(?x)\n \\b\n ([[:alpha:]_]\\w*) \\s* (:)\n",
"begin": "(?x)\n \\b\n ([a-zA-Z_]\\w*) \\s* (:)\n",
"end": "(,)|(?=\\))",
"beginCaptures": {
"1": {
Expand Down Expand Up @@ -795,7 +796,7 @@
"function_call": {
"name": "meta.function-call.gdscript",
"comment": "Regular function call of the type \"name(args)\"",
"begin": "(?x)\n \\b(?=\n ([[:alpha:]_]\\w*) \\s* (\\()\n )\n",
"begin": "(?x)\n \\b(?=\n ([a-zA-Z_]\\w*) \\s* (\\()\n )\n",
"end": "(\\))",
"endCaptures": {
"1": {
Expand All @@ -822,7 +823,7 @@
{
"comment": "Some color schemas support meta.function-call.generic scope",
"name": "support.function.any-method.gdscript",
"match": "(?x)\n \\b ([[:alpha:]_]\\w*) \\b\n"
"match": "(?x)\n \\b ([a-zA-Z_]\\w*) \\b\n"
}
]
},
Expand All @@ -841,7 +842,7 @@
"match": "(,)"
},
{
"match": "\\b([[:alpha:]_]\\w*)\\s*(=)(?!=)",
"match": "\\b([a-zA-Z_]\\w*)\\s*(=)(?!=)",
"captures": {
"1": {
"name": "variable.parameter.function-call.gdscript"
Expand Down
68 changes: 41 additions & 27 deletions syntaxes/GDShader.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
},
"classifier": {
"name": "meta.classifier.gdshader",
"begin": "(?=\b(?:shader_type|render_mode)\b)",
"begin": "(?=\\b(?:shader_type|render_mode)\\b)",
"patterns": [
{
"include": "#comment"
Expand All @@ -95,11 +95,11 @@
},
"classifierKeyword": {
"name": "keyword.language.classifier.gdshader",
"match": "\b(?:shader_type|render_mode)\b"
"match": "\\b(?:shader_type|render_mode)\\b"
},
"identifierClassification": {
"name": "entity.other.inherited-class.gdshader",
"match": "\b[a-z_]+\b"
"match": "\\b[a-z_]+\\b"
},
"definition": {
"patterns": [
Expand Down Expand Up @@ -133,7 +133,7 @@
]
},
"structDefinition": {
"begin": "(?=\b(?:struct)\b)",
"begin": "(?=\\b(?:struct)\\b)",
"patterns": [
{
"include": "#comment"
Expand All @@ -155,11 +155,11 @@
},
"structKeyword": {
"name": "keyword.other.struct.gdshader",
"match": "\b(?:struct)\b"
"match": "\\b(?:struct)\\b"
},
"structName": {
"name": "entity.name.type.struct.gdshader",
"match": "\b[a-zA-Z_]\\w*\b"
"match": "\\b[a-zA-Z_]\\w*\\b"
},
"structDefinitionBlock": {
"name": "meta.definition.block.struct.gdshader",
Expand Down Expand Up @@ -190,7 +190,7 @@
},
"fieldDefinition": {
"name": "meta.definition.field.gdshader",
"begin": "\b[a-zA-Z_]\\w*\b",
"begin": "\\b[a-zA-Z_]\\w*\\b",
"beginCaptures": {
"0": {
"patterns": [
Expand Down Expand Up @@ -225,7 +225,7 @@
},
"fieldName": {
"name": "entity.name.variable.field.gdshader",
"match": "\b[a-zA-Z_]\\w*\b"
"match": "\\b[a-zA-Z_]\\w*\\b"
},
"keyword": {
"patterns": [
Expand Down Expand Up @@ -254,23 +254,23 @@
},
"controlKeyword": {
"name": "keyword.control.gdshader",
"match": "\b(?:if|else|do|while|for|continue|break|switch|case|default|return|discard)\b"
"match": "\\b(?:if|else|do|while|for|continue|break|switch|case|default|return|discard)\\b"
},
"modifierKeyword": {
"name": "storage.modifier.gdshader",
"match": "\b(?:const|global|instance|uniform|varying|in|out|inout|flat|smooth)\b"
"match": "\\b(?:const|global|instance|uniform|varying|in|out|inout|flat|smooth)\\b"
},
"precisionKeyword": {
"name": "storage.type.built-in.primitive.precision.gdshader",
"match": "\b(?:low|medium|high)p\b"
"match": "\\b(?:low|medium|high)p\\b"
},
"typeKeyword": {
"name": "support.type.gdshader",
"match": "\b(?:void|bool|[biu]?vec[234]|u?int|float|mat[234]|[iu]?sampler(?:3D|2D(?:Array)?)|samplerCube)\b"
"match": "\\b(?:void|bool|[biu]?vec[234]|u?int|float|mat[234]|[iu]?sampler(?:3D|2D(?:Array)?)|samplerCube)\\b"
},
"hintKeyword": {
"name": "support.type.annotation.gdshader",
"match": "\b(?:source_color|hint_(?:color|range|(?:black_)?albedo|normal|(?:default_)?(?:white|black)|aniso|anisotropy|roughness_(?:[rgba]|normal|gray))|filter_(?:nearest|linear)(?:_mipmap(?:_anisotropic)?)?|repeat_(?:en|dis)able)\b"
"match": "\\b(?:source_color|hint_(?:color|range|(?:black_)?albedo|normal|(?:default_)?(?:white|black)|aniso|anisotropy|roughness_(?:[rgba]|normal|gray))|filter_(?:nearest|linear)(?:_mipmap(?:_anisotropic)?)?|repeat_(?:en|dis)able)\\b"
},
"element": {
"patterns": [
Expand Down Expand Up @@ -314,51 +314,65 @@
},
"literalFloat": {
"name": "constant.numeric.float.gdshader",
"match": "\b(?:\\d+[eE][-+]?\\d+|(?:\\d*[.]\\d+|\\d+[.])(?:[eE][-+]?\\d+)?)[fF]?"
"match": "\\b(?:\\d+[eE][-+]?\\d+|(?:\\d*[.]\\d+|\\d+[.])(?:[eE][-+]?\\d+)?)[fF]?"
},
"literalInt": {
"name": "constant.numeric.integer.gdshader",
"match": "\b(?:0[xX][0-9A-Fa-f]+|\\d+[uU]?)\b"
"match": "\\b(?:0[xX][0-9A-Fa-f]+|\\d+[uU]?)\\b"
},
"literalBool": {
"name": "constant.language.boolean.gdshader",
"match": "\b(?:false|true)\b"
"match": "\\b(?:false|true)\\b"
},
"identifierType": {
"name": "entity.name.type.gdshader",
"match": "\b[a-zA-Z_]\\w*(?=(?:\\s*\\[\\s*\\w*\\s*\\])?\\s+[a-zA-Z_]\\w*\b)"
"match": "\\b[a-zA-Z_]\\w*(?=(?:\\s*\\[\\s*\\w*\\s*\\])?\\s+[a-zA-Z_]\\w*\\b)"
},
"constructor": {
"name": "entity.name.type.constructor.gdshader",
"match": "\b[a-zA-Z_]\\w*(?=\\s*\\[\\s*\\w*\\s*\\]\\s*[(])|\b[A-Z]\\w*(?=\\s*[(])"
"match": "\\b[a-zA-Z_]\\w*(?=\\s*\\[\\s*\\w*\\s*\\]\\s*[(])|\\b[A-Z]\\w*(?=\\s*[(])"
},
"processorFunction": {
"name": "support.function.gdshader",
"match": "\b(?:vertex|fragment|light|start|process|sky|fog)(?=(?:\\s|/\\*(?:\\*(?!/)|[^*])*\\*/)*[(])"
"match": "\\b(?:vertex|fragment|light|start|process|sky|fog)(?=(?:\\s|/\\*(?:\\*(?!/)|[^*])*\\*/)*[(])"
},
"identifierFunction": {
"name": "entity.name.function.gdshader",
"match": "\b[a-zA-Z_]\\w*(?=(?:\\s|/\\*(?:\\*(?!/)|[^*])*\\*/)*[(])"
"match": "\\b[a-zA-Z_]\\w*(?=(?:\\s|/\\*(?:\\*(?!/)|[^*])*\\*/)*[(])"
},
"swizzling": {
"name": "variable.other.property.gdshader",
"match": "(?<=[.]\\s*)(?:[xyzw]{2,4}|[rgba]{2,4}|[stpq]{2,4})\b"
"match": "([.])\\s*([xyzw]{2,4}|[rgba]{2,4}|[stpq]{2,4})\\b",
"captures": {
"1": {
"name": "punctuation.accessor.gdshader"
},
"2": {
"name": "variable.other.property.gdshader"
}
}
},
"identifierField": {
"name": "entity.name.variable.field.gdshader",
"match": "(?<=[.]\\s*)[a-zA-Z_]\\w*\b"
"match": "([.])\\s*([a-zA-Z_]\\w*)\\b(?!\\s*\\()",
"captures": {
"1": {
"name": "punctuation.accessor.gdshader"
},
"2": {
"name": "entity.name.variable.field.gdshader"
}
}
},
"constantFloat": {
"name": "constant.language.float.gdshader",
"match": "\b(?:E|PI|TAU)\b"
"match": "\\b(?:E|PI|TAU)\\b"
},
"languageVariable": {
"name": "variable.language.gdshader",
"match": "\b(?:[A-Z][A-Z_0-9]*)\b"
"match": "\\b(?:[A-Z][A-Z_0-9]*)\\b"
},
"identifierVariable": {
"name": "variable.name.gdshader",
"match": "\b[a-zA-Z_]\\w*\b"
"match": "\\b[a-zA-Z_]\\w*\\b"
},
"separator": {
"patterns": [
Expand Down
Loading

0 comments on commit 5a67e4c

Please sign in to comment.