mirror of
https://github.com/stan220/godot-docs.git
synced 2026-09-08 17:28:58 +00:00
Update GDScript syntax highlighter
This commit is contained in:
+52
-24
@@ -80,7 +80,9 @@ class GDScriptLexer(RegexLexer):
|
|||||||
(r"[]{}:(),;[]", Punctuation),
|
(r"[]{}:(),;[]", Punctuation),
|
||||||
(r"(\\)(\n)", Whitespace),
|
(r"(\\)(\n)", Whitespace),
|
||||||
(r"\\", Text),
|
(r"\\", Text),
|
||||||
(r"(in|and|or|not)\b", Operator.Word),
|
# modules/gdscript/gdscript.cpp - GDScriptLanguage::get_reserved_words()
|
||||||
|
# Operators.
|
||||||
|
(r"(and|as|in|is|not|or)\b", Operator.Word),
|
||||||
(
|
(
|
||||||
r"!=|==|<<|>>|&&|\+=|-=|\*=|/=|%=|&=|\|=|\|\||[-~+/*%=<>&^.!|$]",
|
r"!=|==|<<|>>|&&|\+=|-=|\*=|/=|%=|&=|\|=|\|\||[-~+/*%=<>&^.!|$]",
|
||||||
Operator,
|
Operator,
|
||||||
@@ -138,26 +140,28 @@ class GDScriptLexer(RegexLexer):
|
|||||||
(
|
(
|
||||||
words(
|
words(
|
||||||
(
|
(
|
||||||
"and",
|
# modules/gdscript/gdscript.cpp - GDScriptLanguage::get_reserved_words()
|
||||||
"await",
|
# Declarations.
|
||||||
"in",
|
|
||||||
"get",
|
|
||||||
"set",
|
|
||||||
"not",
|
|
||||||
"or",
|
|
||||||
"as",
|
|
||||||
"breakpoint",
|
|
||||||
"class",
|
"class",
|
||||||
"class_name",
|
"class_name",
|
||||||
"extends",
|
|
||||||
"is",
|
|
||||||
"func",
|
|
||||||
"signal",
|
|
||||||
"const",
|
"const",
|
||||||
"enum",
|
"enum",
|
||||||
|
"extends",
|
||||||
|
"func",
|
||||||
|
"namespace", # Reserved for potential future use.
|
||||||
|
"signal",
|
||||||
"static",
|
"static",
|
||||||
|
"trait", # Reserved for potential future use.
|
||||||
"var",
|
"var",
|
||||||
|
# Other keywords.
|
||||||
|
"await",
|
||||||
|
"breakpoint",
|
||||||
|
"self",
|
||||||
"super",
|
"super",
|
||||||
|
"yield", # Reserved for potential future use.
|
||||||
|
# Not really keywords, but used in property syntax.
|
||||||
|
"set",
|
||||||
|
"get",
|
||||||
),
|
),
|
||||||
suffix=r"\b",
|
suffix=r"\b",
|
||||||
),
|
),
|
||||||
@@ -168,12 +172,14 @@ class GDScriptLexer(RegexLexer):
|
|||||||
(
|
(
|
||||||
words(
|
words(
|
||||||
(
|
(
|
||||||
|
# modules/gdscript/gdscript.cpp - GDScriptLanguage::get_reserved_words()
|
||||||
|
# Control flow.
|
||||||
"break",
|
"break",
|
||||||
"continue",
|
"continue",
|
||||||
"elif",
|
"elif",
|
||||||
"else",
|
"else",
|
||||||
"if",
|
|
||||||
"for",
|
"for",
|
||||||
|
"if",
|
||||||
"match",
|
"match",
|
||||||
"pass",
|
"pass",
|
||||||
"return",
|
"return",
|
||||||
@@ -196,9 +202,13 @@ class GDScriptLexer(RegexLexer):
|
|||||||
"absf",
|
"absf",
|
||||||
"absi",
|
"absi",
|
||||||
"acos",
|
"acos",
|
||||||
|
"acosh",
|
||||||
|
"angle_difference",
|
||||||
"asin",
|
"asin",
|
||||||
|
"asinh",
|
||||||
"atan",
|
"atan",
|
||||||
"atan2",
|
"atan2",
|
||||||
|
"atanh",
|
||||||
"bezier_derivative",
|
"bezier_derivative",
|
||||||
"bezier_interpolate",
|
"bezier_interpolate",
|
||||||
"bytes_to_var",
|
"bytes_to_var",
|
||||||
@@ -234,6 +244,7 @@ class GDScriptLexer(RegexLexer):
|
|||||||
"is_instance_id_valid",
|
"is_instance_id_valid",
|
||||||
"is_instance_valid",
|
"is_instance_valid",
|
||||||
"is_nan",
|
"is_nan",
|
||||||
|
"is_same",
|
||||||
"is_zero_approx",
|
"is_zero_approx",
|
||||||
"lerp",
|
"lerp",
|
||||||
"lerp_angle",
|
"lerp_angle",
|
||||||
@@ -271,6 +282,7 @@ class GDScriptLexer(RegexLexer):
|
|||||||
"remap",
|
"remap",
|
||||||
"rid_allocate_id",
|
"rid_allocate_id",
|
||||||
"rid_from_int64",
|
"rid_from_int64",
|
||||||
|
"rotate_toward",
|
||||||
"round",
|
"round",
|
||||||
"roundf",
|
"roundf",
|
||||||
"roundi",
|
"roundi",
|
||||||
@@ -290,6 +302,8 @@ class GDScriptLexer(RegexLexer):
|
|||||||
"str_to_var",
|
"str_to_var",
|
||||||
"tan",
|
"tan",
|
||||||
"tanh",
|
"tanh",
|
||||||
|
"type_convert",
|
||||||
|
"type_string",
|
||||||
"typeof",
|
"typeof",
|
||||||
"var_to_bytes",
|
"var_to_bytes",
|
||||||
"var_to_bytes_with_objects",
|
"var_to_bytes_with_objects",
|
||||||
@@ -307,13 +321,13 @@ class GDScriptLexer(RegexLexer):
|
|||||||
"dict_to_inst",
|
"dict_to_inst",
|
||||||
"get_stack",
|
"get_stack",
|
||||||
"inst_to_dict",
|
"inst_to_dict",
|
||||||
|
"is_instance_of",
|
||||||
"len",
|
"len",
|
||||||
"load",
|
"load",
|
||||||
"preload",
|
"preload",
|
||||||
"print_debug",
|
"print_debug",
|
||||||
"print_stack",
|
"print_stack",
|
||||||
"range",
|
"range",
|
||||||
"str",
|
|
||||||
"type_exists",
|
"type_exists",
|
||||||
),
|
),
|
||||||
prefix=r"(?<!\.)",
|
prefix=r"(?<!\.)",
|
||||||
@@ -321,16 +335,18 @@ class GDScriptLexer(RegexLexer):
|
|||||||
),
|
),
|
||||||
Name.Builtin,
|
Name.Builtin,
|
||||||
),
|
),
|
||||||
(r"((?<!\.)(self|super|false|true)|(PI|TAU|NAN|INF)" r")\b", Name.Builtin.Pseudo),
|
# modules/gdscript/gdscript.cpp - GDScriptLanguage::get_reserved_words()
|
||||||
|
# Special values. Constants.
|
||||||
|
(r"((?<!\.)(false|null|true)|(INF|NAN|PI|TAU))\b", Name.Builtin.Pseudo),
|
||||||
(
|
(
|
||||||
words(
|
words(
|
||||||
(
|
(
|
||||||
|
# core/variant/variant.cpp - Variant::get_type_name()
|
||||||
|
# `Nil` is excluded because it is not allowed in GDScript.
|
||||||
"bool",
|
"bool",
|
||||||
"int",
|
"int",
|
||||||
"float",
|
"float",
|
||||||
"String",
|
"String",
|
||||||
"StringName",
|
|
||||||
"NodePath",
|
|
||||||
"Vector2",
|
"Vector2",
|
||||||
"Vector2i",
|
"Vector2i",
|
||||||
"Rect2",
|
"Rect2",
|
||||||
@@ -338,16 +354,21 @@ class GDScriptLexer(RegexLexer):
|
|||||||
"Transform2D",
|
"Transform2D",
|
||||||
"Vector3",
|
"Vector3",
|
||||||
"Vector3i",
|
"Vector3i",
|
||||||
"AABB",
|
|
||||||
"Plane",
|
|
||||||
"Quaternion",
|
|
||||||
"Vector4",
|
"Vector4",
|
||||||
"Vector4i",
|
"Vector4i",
|
||||||
|
"Plane",
|
||||||
|
"AABB",
|
||||||
|
"Quaternion",
|
||||||
"Basis",
|
"Basis",
|
||||||
"Transform3D",
|
"Transform3D",
|
||||||
|
"Projection",
|
||||||
"Color",
|
"Color",
|
||||||
"RID",
|
"RID",
|
||||||
"Object",
|
"Object",
|
||||||
|
"Callable",
|
||||||
|
"Signal",
|
||||||
|
"StringName",
|
||||||
|
"NodePath",
|
||||||
"Dictionary",
|
"Dictionary",
|
||||||
"Array",
|
"Array",
|
||||||
"PackedByteArray",
|
"PackedByteArray",
|
||||||
@@ -358,9 +379,10 @@ class GDScriptLexer(RegexLexer):
|
|||||||
"PackedStringArray",
|
"PackedStringArray",
|
||||||
"PackedVector2Array",
|
"PackedVector2Array",
|
||||||
"PackedVector3Array",
|
"PackedVector3Array",
|
||||||
"PackedVector4Array",
|
|
||||||
"PackedColorArray",
|
"PackedColorArray",
|
||||||
"null",
|
"PackedVector4Array",
|
||||||
|
# The following are also considered types in GDScript.
|
||||||
|
"Variant",
|
||||||
"void",
|
"void",
|
||||||
),
|
),
|
||||||
prefix=r"(?<!\.)",
|
prefix=r"(?<!\.)",
|
||||||
@@ -373,9 +395,11 @@ class GDScriptLexer(RegexLexer):
|
|||||||
(
|
(
|
||||||
words(
|
words(
|
||||||
(
|
(
|
||||||
|
# modules/gdscript/doc_classes/@GDScript.xml
|
||||||
"@export",
|
"@export",
|
||||||
"@export_category",
|
"@export_category",
|
||||||
"@export_color_no_alpha",
|
"@export_color_no_alpha",
|
||||||
|
"@export_custom",
|
||||||
"@export_dir",
|
"@export_dir",
|
||||||
"@export_enum",
|
"@export_enum",
|
||||||
"@export_exp_easing",
|
"@export_exp_easing",
|
||||||
@@ -387,6 +411,7 @@ class GDScriptLexer(RegexLexer):
|
|||||||
"@export_flags_3d_navigation",
|
"@export_flags_3d_navigation",
|
||||||
"@export_flags_3d_physics",
|
"@export_flags_3d_physics",
|
||||||
"@export_flags_3d_render",
|
"@export_flags_3d_render",
|
||||||
|
"@export_flags_avoidance",
|
||||||
"@export_global_dir",
|
"@export_global_dir",
|
||||||
"@export_global_file",
|
"@export_global_file",
|
||||||
"@export_group",
|
"@export_group",
|
||||||
@@ -394,10 +419,13 @@ class GDScriptLexer(RegexLexer):
|
|||||||
"@export_node_path",
|
"@export_node_path",
|
||||||
"@export_placeholder",
|
"@export_placeholder",
|
||||||
"@export_range",
|
"@export_range",
|
||||||
|
"@export_storage",
|
||||||
"@export_subgroup",
|
"@export_subgroup",
|
||||||
|
"@export_tool_button",
|
||||||
"@icon",
|
"@icon",
|
||||||
"@onready",
|
"@onready",
|
||||||
"@rpc",
|
"@rpc",
|
||||||
|
"@static_unload",
|
||||||
"@tool",
|
"@tool",
|
||||||
"@warning_ignore",
|
"@warning_ignore",
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user