From b646c65bed200022d2ed3c2c301387b4f5ea2ad4 Mon Sep 17 00:00:00 2001 From: Danil Alexeev Date: Thu, 31 Oct 2024 19:48:19 +0300 Subject: [PATCH] Update GDScript syntax highlighter --- _extensions/gdscript.py | 76 ++++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 24 deletions(-) diff --git a/_extensions/gdscript.py b/_extensions/gdscript.py index 5da987c46..59c99cc3f 100644 --- a/_extensions/gdscript.py +++ b/_extensions/gdscript.py @@ -80,7 +80,9 @@ class GDScriptLexer(RegexLexer): (r"[]{}:(),;[]", Punctuation), (r"(\\)(\n)", Whitespace), (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"!=|==|<<|>>|&&|\+=|-=|\*=|/=|%=|&=|\|=|\|\||[-~+/*%=<>&^.!|$]", Operator, @@ -138,26 +140,28 @@ class GDScriptLexer(RegexLexer): ( words( ( - "and", - "await", - "in", - "get", - "set", - "not", - "or", - "as", - "breakpoint", + # modules/gdscript/gdscript.cpp - GDScriptLanguage::get_reserved_words() + # Declarations. "class", "class_name", - "extends", - "is", - "func", - "signal", "const", "enum", + "extends", + "func", + "namespace", # Reserved for potential future use. + "signal", "static", + "trait", # Reserved for potential future use. "var", + # Other keywords. + "await", + "breakpoint", + "self", "super", + "yield", # Reserved for potential future use. + # Not really keywords, but used in property syntax. + "set", + "get", ), suffix=r"\b", ), @@ -168,12 +172,14 @@ class GDScriptLexer(RegexLexer): ( words( ( + # modules/gdscript/gdscript.cpp - GDScriptLanguage::get_reserved_words() + # Control flow. "break", "continue", "elif", "else", - "if", "for", + "if", "match", "pass", "return", @@ -196,9 +202,13 @@ class GDScriptLexer(RegexLexer): "absf", "absi", "acos", + "acosh", + "angle_difference", "asin", + "asinh", "atan", "atan2", + "atanh", "bezier_derivative", "bezier_interpolate", "bytes_to_var", @@ -234,6 +244,7 @@ class GDScriptLexer(RegexLexer): "is_instance_id_valid", "is_instance_valid", "is_nan", + "is_same", "is_zero_approx", "lerp", "lerp_angle", @@ -271,6 +282,7 @@ class GDScriptLexer(RegexLexer): "remap", "rid_allocate_id", "rid_from_int64", + "rotate_toward", "round", "roundf", "roundi", @@ -290,6 +302,8 @@ class GDScriptLexer(RegexLexer): "str_to_var", "tan", "tanh", + "type_convert", + "type_string", "typeof", "var_to_bytes", "var_to_bytes_with_objects", @@ -307,13 +321,13 @@ class GDScriptLexer(RegexLexer): "dict_to_inst", "get_stack", "inst_to_dict", + "is_instance_of", "len", "load", "preload", "print_debug", "print_stack", "range", - "str", "type_exists", ), prefix=r"(?