summaryrefslogtreecommitdiff
path: root/src/pyparsing.py
diff options
context:
space:
mode:
authorPaul McGuire <ptmcg@austin.rr.com>2016-05-13 01:37:03 +0000
committerPaul McGuire <ptmcg@austin.rr.com>2016-05-13 01:37:03 +0000
commit27fa3814d29f19e3ad04aa07fc424ab8e79a4781 (patch)
tree0ab0dc480b854a0bc6876f9dd590055a732e8e61 /src/pyparsing.py
parent95d2b47a9ce67a1c5d2e08305ddeff69241d9091 (diff)
downloadpyparsing-git-27fa3814d29f19e3ad04aa07fc424ab8e79a4781.tar.gz
Add epydoc docstrings to new expressions in pyparsing_common
Diffstat (limited to 'src/pyparsing.py')
-rw-r--r--src/pyparsing.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/pyparsing.py b/src/pyparsing.py
index f6a7cab..18f788a 100644
--- a/src/pyparsing.py
+++ b/src/pyparsing.py
@@ -3860,7 +3860,7 @@ commaSeparatedList = delimitedList( Optional( quotedString.copy() | _commasepite
# some other useful expressions - using lower-case class name since we are really using this as a namespace
class pyparsing_common:
"""
- Here are some common low-level expressions that may be useful in jump-starting your parser development:
+ Here are some common low-level expressions that may be useful in jump-starting parser development:
- numeric forms (integers, reals, scientific notation)
- parse actions for converting numeric strings to Python int and/or float types
- common programming identifiers
@@ -3879,18 +3879,26 @@ class pyparsing_common:
return float(t[0])
integer = Word(nums).setName("integer").setParseAction(convertToInteger)
+ """expression that parses an unsigned integer and returns an int"""
+
signedInteger = Regex(r'[+-]?\d+').setName("signed integer").setParseAction(convertToInteger)
+ """expression that parses an integer with optional leading sign and returns an int"""
+
real = Regex(r'[+-]?\d+\.\d*').setName("real number").setParseAction(convertToFloat)
+ """expression that parses a floating point number and returns a float"""
+
sciReal = Regex(r'[+-]?\d+([eE][+-]?\d+|\.\d*([eE][+-]?\d+)?)').setName("real number with scientfic notation").setParseAction(convertToFloat)
+ """expression that parses a floating point number with optional scientfic notation and returns a float"""
# streamlining this expression makes the docs nicer-looking
numeric = (sciReal | real | signedInteger).streamline()
+ """any numeric expression, returns the corresponding Python type"""
- # any int or real number, returned as float
number = Regex(r'[+-]?\d+\.?\d*([eE][+-]?\d+)?').setName("number").setParseAction(convertToFloat)
+ """any int or real number, returned as float"""
- # typical code identifiers
identifier = Word(alphas+'_', alphanums+'_').setName("identifier")
+ """typical code identifier"""
if __name__ == "__main__":