@@ -56,7 +56,7 @@ def _combinations(*l):
5656Whitespace = r'[ \f\t]*'
5757Comment = r'#[^\r\n]*'
5858Ignore = Whitespace + any (r'\\\r?\n' + Whitespace ) + maybe (Comment )
59- Name = r'[a-zA-Z_]\w* '
59+ Name = r'\w+ '
6060
6161Binnumber = r'0[bB]_?[01]+(?:_[01]+)*'
6262Hexnumber = r'0[xX]_?[\da-fA-F]+(?:_[\da-fA-F]+)*[lL]?'
@@ -107,8 +107,8 @@ def _combinations(*l):
107107PseudoExtras = group (r'\\\r?\n' , Comment , Triple )
108108PseudoToken = Whitespace + group (PseudoExtras , Number , Funny , ContStr , Name )
109109
110- tokenprog , pseudoprog , single3prog , double3prog = list ( map (
111- re .compile , (Token , PseudoToken , Single3 , Double3 )))
110+ tokenprog , pseudoprog , single3prog , double3prog = map (
111+ re .compile , (Token , PseudoToken , Single3 , Double3 ))
112112
113113_strprefixes = (
114114 _combinations ('r' , 'R' , 'f' , 'F' ) |
@@ -349,7 +349,6 @@ def generate_tokens(readline):
349349 logical line; continuation lines are included.
350350 """
351351 lnum = parenlev = continued = 0
352- namechars , numchars = string .ascii_letters + '_' , '0123456789'
353352 contstr , needcont = '' , 0
354353 contline = None
355354 indents = [0 ]
@@ -451,7 +450,7 @@ def generate_tokens(readline):
451450 spos , epos , pos = (lnum , start ), (lnum , end ), end
452451 token , initial = line [start :end ], line [start ]
453452
454- if initial in numchars or \
453+ if initial in string . digits or \
455454 (initial == '.' and token != '.' ): # ordinary number
456455 yield (NUMBER , token , spos , epos , line )
457456 elif initial in '\r \n ' :
@@ -501,7 +500,7 @@ def generate_tokens(readline):
501500 yield stashed
502501 stashed = None
503502 yield (STRING , token , spos , epos , line )
504- elif initial in namechars : # ordinary name
503+ elif initial . isidentifier (): # ordinary name
505504 if token in ('async' , 'await' ):
506505 if async_def :
507506 yield (ASYNC if token == 'async' else AWAIT ,
0 commit comments