mirror of
https://github.com/python/cpython.git
synced 2025-09-18 22:50:26 +00:00
Added support for imaginary constants (e.g. 0j, 1j, 1.0j).
This commit is contained in:
parent
c43b685054
commit
b5dc5e3d7e
1 changed files with 5 additions and 4 deletions
|
@ -14,7 +14,7 @@ tokenizer exactly.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__version__ = "Ka-Ping Yee, 4 March 1997, updated by GvR, 6 March 1997"
|
__version__ = "Ka-Ping Yee, 4 March 1997, updated by GvR, 10 March 1997"
|
||||||
|
|
||||||
import string, regex
|
import string, regex
|
||||||
from token import *
|
from token import *
|
||||||
|
@ -24,14 +24,15 @@ def group(*choices): return '\(' + string.join(choices, '\|') + '\)'
|
||||||
Ignore = '[ \f\t]*\([\]\r?\n[ \t]*\)*\(#.*\)?'
|
Ignore = '[ \f\t]*\([\]\r?\n[ \t]*\)*\(#.*\)?'
|
||||||
Name = '[a-zA-Z_][a-zA-Z0-9_]*'
|
Name = '[a-zA-Z_][a-zA-Z0-9_]*'
|
||||||
|
|
||||||
|
ImagZero = '0[jJ]' # This is not caught by any of the following
|
||||||
Hexnumber = '0[xX][0-9a-fA-F]*[lL]?'
|
Hexnumber = '0[xX][0-9a-fA-F]*[lL]?'
|
||||||
Octnumber = '0[0-7]*[lL]?'
|
Octnumber = '0[0-7]*[lL]?'
|
||||||
Decnumber = '[1-9][0-9]*[lL]?'
|
Decnumber = '[1-9][0-9]*[lLjJ]?'
|
||||||
Intnumber = group(Hexnumber, Octnumber, Decnumber)
|
Intnumber = group(ImagZero, Hexnumber, Octnumber, Decnumber)
|
||||||
Exponent = '[eE][-+]?[0-9]+'
|
Exponent = '[eE][-+]?[0-9]+'
|
||||||
Pointfloat = group('[0-9]+\.[0-9]*', '\.[0-9]+') + group(Exponent) + '?'
|
Pointfloat = group('[0-9]+\.[0-9]*', '\.[0-9]+') + group(Exponent) + '?'
|
||||||
Expfloat = '[0-9]+' + Exponent
|
Expfloat = '[0-9]+' + Exponent
|
||||||
Floatnumber = group(Pointfloat, Expfloat)
|
Floatnumber = group(Pointfloat, Expfloat) + "[jJ]?"
|
||||||
Number = group(Floatnumber, Intnumber)
|
Number = group(Floatnumber, Intnumber)
|
||||||
|
|
||||||
Single = group('^\'', '[^\]\'')
|
Single = group('^\'', '[^\]\'')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue