{
  "name": "gdshader",
  "scopeName": "source.gdshader",
  "uuid": "3a95d25d-688b-481f-a581-eee47f00e5ca",
  "fileTypes": ["gdshader"],
  "patterns": [
    {
      "include": "#any"
    }
  ],
  "repository": {
    "any": {
      "patterns": [
        {
          "include": "#comment"
        },
        {
          "include": "#enclosed"
        },
        {
          "include": "#classifier"
        },
        {
          "include": "#definition"
        },
        {
          "include": "#keyword"
        },
        {
          "include": "#element"
        },
        {
          "include": "#separator"
        },
        {
          "include": "#operator"
        }
      ]
    },
    "comment": {
      "patterns": [
        {
          "include": "#commentLine"
        },
        {
          "include": "#commentBlock"
        }
      ]
    },
    "commentLine": {
      "name": "comment.line.double-slash.gdshader",
      "begin": "//",
      "end": "$"
    },
    "commentBlock": {
      "name": "comment.block.gdshader",
      "begin": "/\\*",
      "end": "\\*/"
    },
    "enclosed": {
      "name": "meta.parenthesis.gdshader",
      "begin": "\\(",
      "end": "\\)",
      "captures": {
        "0": {
          "name": "punctuation.parenthesis.gdshader"
        }
      },
      "patterns": [
        {
          "include": "#any"
        }
      ]
    },
    "classifier": {
      "name": "meta.classifier.gdshader",
      "begin": "(?=\\b(?:shader_type|render_mode)\\b)",
      "patterns": [
        {
          "include": "#comment"
        },
        {
          "include": "#keyword"
        },
        {
          "include": "#identifierClassification"
        },
        {
          "include": "#separator"
        }
      ],
      "end": "(?<=;)"
    },
    "classifierKeyword": {
      "name": "keyword.language.classifier.gdshader",
      "match": "\\b(?:shader_type|render_mode)\\b"
    },
    "identifierClassification": {
      "name": "entity.other.inherited-class.gdshader",
      "match": "\\b[a-z_]+\\b"
    },
    "definition": {
      "patterns": [
        {
          "include": "#structDefinition"
        }
      ]
    },
    "arraySize": {
      "name": "meta.array-size.gdshader",
      "begin": "\\[",
      "end": "\\]",
      "captures": {
        "0": {
          "name": "punctuation.bracket.gdshader"
        }
      },
      "patterns": [
        {
          "include": "#comment"
        },
        {
          "include": "#keyword"
        },
        {
          "include": "#element"
        },
        {
          "include": "#separator"
        }
      ]
    },
    "structDefinition": {
      "begin": "(?=\\b(?:struct)\\b)",
      "patterns": [
        {
          "include": "#comment"
        },
        {
          "include": "#keyword"
        },
        {
          "include": "#structName"
        },
        {
          "include": "#structDefinitionBlock"
        },
        {
          "include": "#separator"
        }
      ],
      "end": "(?<=;)"
    },
    "structKeyword": {
      "name": "keyword.other.struct.gdshader",
      "match": "\\b(?:struct)\\b"
    },
    "structName": {
      "name": "entity.name.type.struct.gdshader",
      "match": "\\b[a-zA-Z_]\\w*\\b"
    },
    "structDefinitionBlock": {
      "name": "meta.definition.block.struct.gdshader",
      "begin": "\\{",
      "end": "\\}",
      "captures": {
        "0": {
          "name": "punctuation.definition.block.struct.gdshader"
        }
      },
      "patterns": [
        {
          "include": "#comment"
        },
        {
          "include": "#precisionKeyword"
        },
        {
          "include": "#fieldDefinition"
        },
        {
          "include": "#keyword"
        },
        {
          "include": "#any"
        }
      ]
    },
    "fieldDefinition": {
      "name": "meta.definition.field.gdshader",
      "begin": "\\b[a-zA-Z_]\\w*\\b",
      "beginCaptures": {
        "0": {
          "patterns": [
            {
              "include": "#typeKeyword"
            },
            {
              "match": ".+",
              "name": "entity.name.type.gdshader"
            }
          ]
        }
      },
      "patterns": [
        {
          "include": "#comment"
        },
        {
          "include": "#keyword"
        },
        {
          "include": "#arraySize"
        },
        {
          "include": "#fieldName"
        },
        {
          "include": "#any"
        }
      ],
      "end": "(?<=;)"
    },
    "fieldName": {
      "name": "entity.name.variable.field.gdshader",
      "match": "\\b[a-zA-Z_]\\w*\\b"
    },
    "keyword": {
      "patterns": [
        {
          "include": "#classifierKeyword"
        },
        {
          "include": "#structKeyword"
        },
        {
          "include": "#controlKeyword"
        },
        {
          "include": "#modifierKeyword"
        },
        {
          "include": "#precisionKeyword"
        },
        {
          "include": "#typeKeyword"
        },
        {
          "include": "#hintKeyword"
        }
      ]
    },
    "controlKeyword": {
      "name": "keyword.control.gdshader",
      "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"
    },
    "precisionKeyword": {
      "name": "storage.type.built-in.primitive.precision.gdshader",
      "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"
    },
    "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"
    },
    "element": {
      "patterns": [
        {
          "include": "#literalFloat"
        },
        {
          "include": "#literalInt"
        },
        {
          "include": "#literalBool"
        },
        {
          "include": "#identifierType"
        },
        {
          "include": "#constructor"
        },
        {
          "include": "#processorFunction"
        },
        {
          "include": "#identifierFunction"
        },
        {
          "include": "#swizzling"
        },
        {
          "include": "#identifierField"
        },
        {
          "include": "#constantFloat"
        },
        {
          "include": "#languageVariable"
        },
        {
          "include": "#identifierVariable"
        }
      ]
    },
    "literalFloat": {
      "name": "constant.numeric.float.gdshader",
      "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"
    },
    "literalBool": {
      "name": "constant.language.boolean.gdshader",
      "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)"
    },
    "constructor": {
      "name": "entity.name.type.constructor.gdshader",
      "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|/\\*(?:\\*(?!/)|[^*])*\\*/)*[(])"
    },
    "identifierFunction": {
      "name": "entity.name.function.gdshader",
      "match": "\\b[a-zA-Z_]\\w*(?=(?:\\s|/\\*(?:\\*(?!/)|[^*])*\\*/)*[(])"
    },
    "swizzling": {
      "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": {
      "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"
    },
    "languageVariable": {
      "name": "variable.language.gdshader",
      "match": "\\b(?:[A-Z][A-Z_0-9]*)\\b"
    },
    "identifierVariable": {
      "name": "variable.name.gdshader",
      "match": "\\b[a-zA-Z_]\\w*\\b"
    },
    "separator": {
      "patterns": [
        {
          "match": "[.]",
          "name": "punctuation.accessor.gdshader"
        },
        {
          "include": "#separatorComma"
        },
        {
          "match": "[;]",
          "name": "punctuation.terminator.statement.gdshader"
        },
        {
          "match": "[:]",
          "name": "keyword.operator.type.annotation.gdshader"
        }
      ]
    },
    "separatorComma": {
      "name": "punctuation.separator.comma.gdshader",
      "match": "[,]"
    },
    "operator": {
      "name": "keyword.operator.gdshader",
      "match": "\\<\\<\\=?|\\>\\>\\=?|[-+*/&|<>=!]\\=|\\&\\&|[|][|]|[-+~!*/%<>&^|=]"
    }
  }
}
