mirror of
https://github.com/python/cpython.git
synced 2025-08-22 01:35:16 +00:00
Make ELLIPSIS a separate token. This makes it a syntax error to write ". . ." for Ellipsis.
This commit is contained in:
parent
428f0641ec
commit
dde002899d
9 changed files with 111 additions and 95 deletions
|
@ -83,7 +83,7 @@ Operator = group(r"\*\*=?", r">>=?", r"<<=?", r"!=",
|
|||
r"~")
|
||||
|
||||
Bracket = '[][(){}]'
|
||||
Special = group(r'\r?\n', r'[:;.,@]')
|
||||
Special = group(r'\r?\n', r'\.\.\.', r'[:;.,@]')
|
||||
Funny = group(Operator, Bracket, Special)
|
||||
|
||||
PlainToken = group(Number, Funny, String, Name)
|
||||
|
@ -334,8 +334,8 @@ def generate_tokens(readline):
|
|||
spos, epos, pos = (lnum, start), (lnum, end), end
|
||||
token, initial = line[start:end], line[start]
|
||||
|
||||
if initial in numchars or \
|
||||
(initial == '.' and token != '.'): # ordinary number
|
||||
if (initial in numchars or # ordinary number
|
||||
(initial == '.' and token != '.' and token != '...')):
|
||||
yield (NUMBER, token, spos, epos, line)
|
||||
elif initial in '\r\n':
|
||||
yield (NL if parenlev > 0 else NEWLINE,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue