diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2019-06-29 02:14:57 -0500 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2019-06-29 02:14:57 -0500 |
commit | f5de46966a55b8c651f7ff92440665af02567df4 (patch) | |
tree | 5967a3d9fc6caa04307c60ab51c3fd7bca632a9d /pyparsing.py | |
parent | 3f01989e4ee04bcb2d71008efa989f48bd7a5123 (diff) | |
download | pyparsing-git-f5de46966a55b8c651f7ff92440665af02567df4.tar.gz |
Fix up changes to parse reals without leading digits before the decimal, and add unit tests
Diffstat (limited to 'pyparsing.py')
-rw-r--r-- | pyparsing.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/pyparsing.py b/pyparsing.py index 3688181..fe9b8cb 100644 --- a/pyparsing.py +++ b/pyparsing.py @@ -96,7 +96,7 @@ classes inherit from. Use the docstrings for examples of how to: """ __version__ = "2.4.1" -__versionTime__ = "29 Jun 2019 06:17 UTC" +__versionTime__ = "29 Jun 2019 06:56 UTC" __author__ = "Paul McGuire <ptmcg@users.sourceforge.net>" import string @@ -6166,10 +6166,10 @@ class pyparsing_common: """mixed integer of the form 'integer - fraction', with optional leading integer, returns float""" mixed_integer.addParseAction(sum) - real = Regex(r'[+-]?\d*\.\d*').setName("real number").setParseAction(convertToFloat) + real = Regex(r'[+-]?(:?\d+\.\d*|\.\d+)').setName("real number").setParseAction(convertToFloat) """expression that parses a floating point number and returns a float""" - sci_real = Regex(r'[+-]?\d*([eE][+-]?\d+|\.\d*([eE][+-]?\d+)?)').setName("real number with scientific notation").setParseAction(convertToFloat) + sci_real = Regex(r'[+-]?(:?\d+(:?[eE][+-]?\d+)|(:?\d+\.\d*|\.\d+)(:?[eE][+-]?\d+)?)').setName("real number with scientific notation").setParseAction(convertToFloat) """expression that parses a floating point number with optional scientific notation and returns a float""" |