Improve GDScript lexer for Godot 3.x

- Add binary literals.
- Update list of built-in functions for Godot 3.4.
This commit is contained in:
Hugo Locurcio
2022-02-14 14:09:56 +01:00
parent af1135ea98
commit bad5f91416

View File

@@ -190,6 +190,7 @@ class GDScriptLexer(RegexLexer):
"atan",
"atan2",
"bytes2var",
"cartesian2polar",
"ceil",
"char",
"clamp",
@@ -199,6 +200,7 @@ class GDScriptLexer(RegexLexer):
"db2linear",
"decimals",
"dectime",
"deep_equal",
"deg2rad",
"dict2inst",
"ease",
@@ -207,26 +209,41 @@ class GDScriptLexer(RegexLexer):
"fmod",
"fposmod",
"funcref",
"get_stack",
"hash",
"inst2dict",
"instance_from_id",
"inverse_lerp",
"is_equal_approx",
"is_inf",
"is_instance_valid",
"is_nan",
"is_zero_approx",
"len",
"lerp",
"lerp_angle",
"linear2db",
"load",
"log",
"max",
"min",
"move_toward",
"nearest_po2",
"ord",
"parse_json",
"polar2cartesian",
"posmod",
"pow",
"preload",
"print",
"print_debug",
"print_stack",
"printerr",
"printraw",
"prints",
"printt",
"push_error",
"push_warning",
"rad2deg",
"rand_range",
"rand_seed",
@@ -234,23 +251,29 @@ class GDScriptLexer(RegexLexer):
"randi",
"randomize",
"range",
"range_lerp",
"round",
"seed",
"sign",
"sin",
"sinh",
"smoothstep",
"sqrt",
"step_decimals",
"stepify",
"str",
"str2var",
"tan",
"tan",
"tanh",
"type_exist",
"to_json",
"type_exists",
"typeof",
"validate_json",
"var2bytes",
"var2str",
"weakref",
"wrapf",
"wrapi",
"yield",
),
prefix=r"(?<!\.)",
@@ -300,7 +323,8 @@ class GDScriptLexer(RegexLexer):
"numbers": [
(r"(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?", Number.Float),
(r"\d+[eE][+-]?[0-9]+j?", Number.Float),
(r"0[xX][a-fA-F0-9]+", Number.Hex),
(r"0x[a-fA-F0-9]+", Number.Hex),
(r"0b[01]+", Number.Bin),
(r"\d+j?", Number.Integer),
],
"name": [(r"[a-zA-Z_]\w*", Name)],