summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2016-05-18 14:08:34 +0000
committerptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2016-05-18 14:08:34 +0000
commit0f599d46a75de41bea21a1cbd472b63b8775ead0 (patch)
tree4da8c6d8eca6c84ea45647314e9d27bf7738c7e7
parentd785871a32632fb0c2602aa839fd0c688a4b54c5 (diff)
downloadpyparsing-0f599d46a75de41bea21a1cbd472b63b8775ead0.tar.gz
Add hex_integer to pyparsing_common
git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/trunk@356 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b
-rw-r--r--src/pyparsing.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/pyparsing.py b/src/pyparsing.py
index be90545..2fb471e 100644
--- a/src/pyparsing.py
+++ b/src/pyparsing.py
@@ -3917,6 +3917,9 @@ class pyparsing_common:
integer = Word(nums).setName("integer").setParseAction(convertToInteger)
"""expression that parses an unsigned integer and returns an int"""
+ hex_integer = Word(hexnums).setName("hex integer").setParseAction(lambda t: int(t[0], 16))
+ """expression that parses a hexadecimal 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"""