From 2cf33fcefb1dace6ec1d714368c20aaf89656692 Mon Sep 17 00:00:00 2001 From: ptmcg Date: Fri, 3 Mar 2017 00:52:59 +0000 Subject: 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 --- src/examples/btpyparse.py | 6 +++--- src/examples/invRegex.py | 4 ++-- src/examples/pythonGrammarParser.py | 2 +- src/examples/verilogParse.py | 2 +- 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 -- cgit v1.2.1