summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2017-03-03 00:52:59 +0000
committerptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2017-03-03 00:52:59 +0000
commit2cf33fcefb1dace6ec1d714368c20aaf89656692 (patch)
tree48d7b23cbcf588ba9cb0842fe624d8bbcc3280e3
parent5c11d34e6d837648cfae2e9728a190c134915ccb (diff)
downloadpyparsing-2cf33fcefb1dace6ec1d714368c20aaf89656692.tar.gz
Fix deprecated use of '\' as described in https://bugs.python.org/issue27364 (Deprecated in Python 3.6, will become SyntaxError in a future release)
git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/trunk@457 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b
-rw-r--r--src/examples/btpyparse.py6
-rw-r--r--src/examples/invRegex.py4
-rw-r--r--src/examples/pythonGrammarParser.py2
-rw-r--r--src/examples/verilogParse.py2
4 files changed, 7 insertions, 7 deletions
diff --git a/src/examples/btpyparse.py b/src/examples/btpyparse.py
index 6720c19..4fbbac8 100644
--- a/src/examples/btpyparse.py
+++ b/src/examples/btpyparse.py
@@ -54,16 +54,16 @@ number = Regex('[0-9]+')
# Basis characters (by exclusion) for variable / field names. The following
# list of characters is from the btparse documentation
-any_name = Regex('[^\s"#%\'(),={}]+')
+any_name = Regex('[^\\s"#%\'(),={}]+')
# btparse says, and the test bibs show by experiment, that macro and field names
# cannot start with a digit. In fact entry type names cannot start with a digit
# either (see tests/bibs). Cite keys can start with a digit
-not_digname = Regex('[^\d\s"#%\'(),={}][^\s"#%\'(),={}]*')
+not_digname = Regex('[^\\d\\s"#%\'(),={}][^\\s"#%\'(),={}]*')
# Comment comments out to end of line
comment = (AT + CaselessLiteral('comment') +
- Regex("[\s{(].*").leaveWhitespace())
+ Regex(r"[\s{(].*").leaveWhitespace())
# The name types with their digiteyness
not_dig_lower = not_digname.copy().setParseAction(lambda t: t[0].lower())
diff --git a/src/examples/invRegex.py b/src/examples/invRegex.py
index b6fe1f1..aea3b55 100644
--- a/src/examples/invRegex.py
+++ b/src/examples/invRegex.py
@@ -188,9 +188,9 @@ def count(gen):
return sum(1 for _ in gen)
def invert(regex):
- """Call this routine as a generator to return all the strings that
+ r"""Call this routine as a generator to return all the strings that
match the input regular expression.
- for s in invert("[A-Z]{3}\d{3}"):
+ for s in invert(r"[A-Z]{3}\d{3}"):
print s
"""
invReGenerator = GroupEmitter(parser().parseString(regex)).makeGenerator()
diff --git a/src/examples/pythonGrammarParser.py b/src/examples/pythonGrammarParser.py
index f0631b8..f199917 100644
--- a/src/examples/pythonGrammarParser.py
+++ b/src/examples/pythonGrammarParser.py
@@ -9,7 +9,7 @@ from pyparsing import *
# this just skips that step and inlines the bnf text directly - this grammar was taken from
# Python 2.4.1
#
-grammar = """
+grammar = r"""
# Grammar for Python
# Note: Changing the grammar specified in this file will most likely
diff --git a/src/examples/verilogParse.py b/src/examples/verilogParse.py
index 2b7fd35..05650df 100644
--- a/src/examples/verilogParse.py
+++ b/src/examples/verilogParse.py
@@ -120,7 +120,7 @@ def Verilog_BNF():
identLead = alphas+"$_"
identBody = alphanums+"$_"
- identifier1 = Regex( r"\.?["+identLead+"]["+identBody+"]*(\.["+identLead+"]["+identBody+"]*)*"
+ identifier1 = Regex( r"\.?["+identLead+"]["+identBody+r"]*(\.["+identLead+"]["+identBody+"]*)*"
).setName("baseIdent")
identifier2 = Regex(r"\\\S+").setParseAction(lambda t:t[0][1:]).setName("escapedIdent")#.setDebug()
identifier = identifier1 | identifier2