3030 String ,
3131 Number ,
3232 Punctuation ,
33+ Whitespace ,
3334)
3435
3536__all__ = ["GDScriptLexer" ]
@@ -65,19 +66,19 @@ def innerstring_rules(ttype):
6566
6667 tokens = {
6768 "root" : [
68- (r"\n" , Text ),
69+ (r"\n" , Whitespace ),
6970 (
7071 r'^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")' ,
71- bygroups (Text , String .Affix , String .Doc ),
72+ bygroups (Whitespace , String .Affix , String .Doc ),
7273 ),
7374 (
7475 r"^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')" ,
75- bygroups (Text , String .Affix , String .Doc ),
76+ bygroups (Whitespace , String .Affix , String .Doc ),
7677 ),
77- (r"[^\S\n]+" , Text ),
78+ (r"[^\S\n]+" , Whitespace ),
7879 (r"#.*$" , Comment .Single ),
7980 (r"[]{}:(),;[]" , Punctuation ),
80- (r"\\\n " , Text ),
81+ (r"(\\)(\n) " , Whitespace ),
8182 (r"\\" , Text ),
8283 (r"(in|and|or|not)\b" , Operator .Word ),
8384 (
@@ -86,8 +87,8 @@ def innerstring_rules(ttype):
8687 ),
8788 include ("keywords" ),
8889 include ("control_flow_keywords" ),
89- (r"(func)((?:\s|\\\s)+)" , bygroups (Keyword , Text ), "funcname" ),
90- (r"(class)((?:\s|\\\s)+)" , bygroups (Keyword , Text ), "classname" ),
90+ (r"(func)((?:\s|\\\s)+)" , bygroups (Keyword , Whitespace ), "funcname" ),
91+ (r"(class)((?:\s|\\\s)+)" , bygroups (Keyword , Whitespace ), "classname" ),
9192 include ("builtins" ),
9293 include ("decorators" ),
9394 (
@@ -359,6 +360,7 @@ def innerstring_rules(ttype):
359360 "PackedVector3iArray" ,
360361 "PackedColorArray" ,
361362 "null" ,
363+ "void" ,
362364 ),
363365 prefix = r"(?<!\.)" ,
364366 suffix = r"\b" ,
@@ -405,11 +407,14 @@ def innerstring_rules(ttype):
405407 ),
406408 ],
407409 "numbers" : [
408- (r"(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?" , Number .Float ),
409- (r"\d+[eE][+-]?[0-9]+j?" , Number .Float ),
410- (r"0x[a-fA-F0-9]+" , Number .Hex ),
411- (r"0b[01]+" , Number .Bin ),
412- (r"\d+j?" , Number .Integer ),
410+ (
411+ r"(-)?((\d|(?<=\d)_)+\.(\d|(?<=\d)_)*|(\d|(?<=\d)_)*\.(\d|(?<=\d)_)+)([eE][+-]?(\d|(?<=\d)_)+)?j?" ,
412+ Number .Float ,
413+ ),
414+ (r"(-)?(\d|(?<=\d)_)+[eE][+-]?(\d|(?<=\d)_)+j?" , Number .Float ),
415+ (r"(-)?0[xX]([a-fA-F0-9]|(?<=[a-fA-F0-9])_)+" , Number .Hex ),
416+ (r"(-)?0[bB]([01]|(?<=[01])_)+" , Number .Bin ),
417+ (r"(-)?(\d|(?<=\d)_)+j?" , Number .Integer ),
413418 ],
414419 "name" : [(r"@?[a-zA-Z_]\w*" , Name )],
415420 "funcname" : [(r"[a-zA-Z_]\w*" , Name .Function , "#pop" ), default ("#pop" )],
@@ -436,12 +441,12 @@ def innerstring_rules(ttype):
436441 "tdqs" : [
437442 (r'"""' , String .Double , "#pop" ),
438443 include ("strings-double" ),
439- (r"\n" , String . Double ),
444+ (r"\n" , Whitespace ),
440445 ],
441446 "tsqs" : [
442447 (r"'''" , String .Single , "#pop" ),
443448 include ("strings-single" ),
444- (r"\n" , String . Single ),
449+ (r"\n" , Whitespace ),
445450 ],
446451 }
447452
0 commit comments