diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-05-03 10:11:51 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-05-03 10:11:51 +1200 |
commit | e35e6d90b977ac19e3816b2a8029a12287c976ac (patch) | |
tree | 25adaa30d685df2f50f8175a4ca71cc042ae858b /libpathod/language/base.py | |
parent | bf71a9a2a03697be4332f51727fa19fc4bcb4c62 (diff) | |
download | mitmproxy-e35e6d90b977ac19e3816b2a8029a12287c976ac.tar.gz mitmproxy-e35e6d90b977ac19e3816b2a8029a12287c976ac.tar.bz2 mitmproxy-e35e6d90b977ac19e3816b2a8029a12287c976ac.zip |
Remove bundled pyparsing, install as external package
Adapt ValueLiteral parsing to suit
Diffstat (limited to 'libpathod/language/base.py')
-rw-r--r-- | libpathod/language/base.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libpathod/language/base.py b/libpathod/language/base.py index e2cd9c9e..c473a6a8 100644 --- a/libpathod/language/base.py +++ b/libpathod/language/base.py @@ -1,7 +1,7 @@ import operator import os import abc -import contrib.pyparsing as pp +import pyparsing as pp from .. import utils from . import generators, exceptions @@ -19,13 +19,11 @@ v_literal = pp.MatchFirst( [ pp.QuotedString( "\"", - escChar="\\", unquoteResults=True, multiline=True ), pp.QuotedString( "'", - escChar="\\", unquoteResults=True, multiline=True ), @@ -86,6 +84,9 @@ class _ValueLiteral(Token): class ValueLiteral(_ValueLiteral): + """ + A literal with Python-style string escaping + """ @classmethod def expr(klass): e = v_literal.copy() @@ -97,8 +98,9 @@ class ValueLiteral(_ValueLiteral): return v def spec(self): - ret = "'%s'"%self.val.encode("string_escape") - return ret + inner = self.val.encode("string_escape") + inner = inner.replace(r"\'", r"\x27") + return "'" + inner + "'" class ValueNakedLiteral(_ValueLiteral): |