diff options
author | ptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b> | 2016-08-05 17:57:13 +0000 |
---|---|---|
committer | ptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b> | 2016-08-05 17:57:13 +0000 |
commit | c4ebbf1551e743122815aa0af3a45b3ecb5528d1 (patch) | |
tree | a8b086a51bfb397fc175501e3eabb036b2eccf46 | |
parent | 0f8a9c8bfaa4fd8b05a0d54b119ffeaab59ef44a (diff) | |
download | pyparsing-c4ebbf1551e743122815aa0af3a45b3ecb5528d1.tar.gz |
Rename pyparsing_common's "numeric" and "number" expressions to "number" and "fnumber", to better indicate which expression forces conversion to float (that is fnumber)
git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/trunk@384 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b
-rw-r--r-- | src/CHANGES | 10 | ||||
-rw-r--r-- | src/pyparsing.py | 10 | ||||
-rw-r--r-- | src/unitTests.py | 6 |
3 files changed, 18 insertions, 8 deletions
diff --git a/src/CHANGES b/src/CHANGES index 47f4858..ea7274e 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -12,6 +12,16 @@ Version 2.1.6 - For Python 2.6 users, will attempt to import from ordereddict
backport. If not present, will implement pure-Python Fifo dict.)
+- Minor API change - to better distinguish between the flexible
+ numeric types defined in pyparsing_common, I've changed "numeric"
+ (which parsed numbers of different types and returned int for ints,
+ float for floats, etc.) and "number" (which parsed numbers of int
+ or float type, and returned all floats) to "number" and "fnumber"
+ respectively. I hope the "f" prefix of "fnumber" will be a better
+ indicator of its internal conversion of parsed values to floats,
+ while the generic "number" is similar to the flexible number syntax
+ in other languages.
+
- Fixed bug in pyparsing_common.numeric, integers were parsed as floats.
diff --git a/src/pyparsing.py b/src/pyparsing.py index 43216a5..a6e4f3b 100644 --- a/src/pyparsing.py +++ b/src/pyparsing.py @@ -58,7 +58,7 @@ The pyparsing module handles some of the problems that are typically vexing when """
__version__ = "2.1.6"
-__versionTime__ = "03 Aug 2016 23:56 UTC"
+__versionTime__ = "05 Aug 2016 17:50 UTC"
__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>"
import string
@@ -4104,10 +4104,10 @@ class pyparsing_common: """expression that parses a floating point number with optional scientific notation and returns a float"""
# streamlining this expression makes the docs nicer-looking
- numeric = (sciReal | real | signedInteger).streamline()
+ number = (sciReal | real | signedInteger).streamline()
"""any numeric expression, returns the corresponding Python type"""
- number = Regex(r'[+-]?\d+\.?\d*([eE][+-]?\d+)?').setName("number").setParseAction(convertToFloat)
+ fnumber = Regex(r'[+-]?\d+\.?\d*([eE][+-]?\d+)?').setName("fnumber").setParseAction(convertToFloat)
"""any int or real number, returned as float"""
identifier = Word(alphas+'_', alphanums+'_').setName("identifier")
@@ -4203,7 +4203,7 @@ if __name__ == "__main__": """)
- pyparsing_common.numeric.runTests("""
+ pyparsing_common.number.runTests("""
100
-100
+100
@@ -4213,7 +4213,7 @@ if __name__ == "__main__": """)
# any int or real number, returned as float
- pyparsing_common.number.runTests("""
+ pyparsing_common.fnumber.runTests("""
100
-100
+100
diff --git a/src/unitTests.py b/src/unitTests.py index 392a905..cddcaf1 100644 --- a/src/unitTests.py +++ b/src/unitTests.py @@ -2700,7 +2700,7 @@ class CommonExpressionsTest(ParseTestCase): """, failureTests=True)[0]
assert success, "error in detecting invalid IPv6 address"
- success = pyparsing_common.numeric.runTests("""
+ success = pyparsing_common.number.runTests("""
100
-100
+100
@@ -2711,7 +2711,7 @@ class CommonExpressionsTest(ParseTestCase): assert success, "error in parsing valid numerics"
# any int or real number, returned as float
- success = pyparsing_common.number.runTests("""
+ success = pyparsing_common.fnumber.runTests("""
100
-100
+100
@@ -2780,7 +2780,7 @@ class CommonExpressionsTest(ParseTestCase): """)[0]
assert success, "failed to parse valid mixed integer"
- success, results = pyparsing_common.numeric.runTests("""
+ success, results = pyparsing_common.number.runTests("""
100
-3
1.732
|