summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenn Knowles <kenn@kennknowles.com>2018-07-30 08:36:51 -0700
committerGitHub <noreply@github.com>2018-07-30 08:36:51 -0700
commit2ceae1039208973e9fe1588011c902e231144efe (patch)
tree84ba43f8c612e734d31ee6fc4ad3180b335fac54
parent7ec055619e6cafb3f98a82713c7198847c36a4cc (diff)
parent320deb5c3a4791b3024bc305f97d2b6c1a53936f (diff)
downloadjsonpath-rw-2ceae1039208973e9fe1588011c902e231144efe.tar.gz
Merge pull request #59: allow # in IDs
-rw-r--r--.travis.yml5
-rw-r--r--jsonpath_rw/lexer.py2
-rw-r--r--tests/test_lexer.py3
3 files changed, 7 insertions, 3 deletions
diff --git a/.travis.yml b/.travis.yml
index 8c18230..3c55ece 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,10 @@ python:
install:
- "pip install ."
- "pip install pytest"
- - "pip install coverage coveralls"
+ - "pip install coveralls"
+ # Coveralls 4.0 doesn't support Python 3.2
+ - if [ "$TRAVIS_PYTHON_VERSION" == "3.2" ]; then pip install coverage==3.7.1; fi
+ - if [ "$TRAVIS_PYTHON_VERSION" != "3.2" ]; then pip install coverage; fi
script: coverage run setup.py test
after_success:
- coveralls
diff --git a/jsonpath_rw/lexer.py b/jsonpath_rw/lexer.py
index aa28ff5..b85b425 100644
--- a/jsonpath_rw/lexer.py
+++ b/jsonpath_rw/lexer.py
@@ -61,7 +61,7 @@ class JsonPathLexer(object):
t_ignore = ' \t'
def t_ID(self, t):
- r'[a-zA-Z_@][a-zA-Z0-9_@\-]*'
+ r'[a-zA-Z_@#][a-zA-Z0-9_@\-]*'
t.type = self.reserved_words.get(t.value, 'ID')
return t
diff --git a/tests/test_lexer.py b/tests/test_lexer.py
index 9d9fe38..481215d 100644
--- a/tests/test_lexer.py
+++ b/tests/test_lexer.py
@@ -53,6 +53,7 @@ class TestLexer(unittest.TestCase):
self.assert_lex_equiv('`this`', [self.token('this', 'NAMED_OPERATOR')])
self.assert_lex_equiv('|', [self.token('|', '|')])
self.assert_lex_equiv('where', [self.token('where', 'WHERE')])
+ self.assert_lex_equiv('a.#text', [self.token('a', 'ID'), self.token('.', '.'), self.token('#text', 'ID')])
def test_basic_errors(self):
def tokenize(s):
@@ -66,4 +67,4 @@ class TestLexer(unittest.TestCase):
self.assertRaises(JsonPathLexerError, tokenize, '"`')
self.assertRaises(JsonPathLexerError, tokenize, "'`")
self.assertRaises(JsonPathLexerError, tokenize, '?')
- self.assertRaises(JsonPathLexerError, tokenize, '$.foo.bar.#')
+ self.assertRaises(JsonPathLexerError, tokenize, '$.foo.bar.%')