55
66import ply .yacc
77
8- from jsonpath_rw .jsonpath import *
9- from jsonpath_rw .lexer import JsonPathLexer
8+ from jsonpath_ng .jsonpath import *
9+ from jsonpath_ng .lexer import JsonPathLexer
1010
1111logger = logging .getLogger (__name__ )
1212
@@ -17,7 +17,7 @@ class JsonPathParser(object):
1717 '''
1818 An LALR-parser for JsonPath
1919 '''
20-
20+
2121 tokens = JsonPathLexer .tokens
2222
2323 def __init__ (self , debug = False , lexer_class = None ):
@@ -40,7 +40,7 @@ def parse_token_stream(self, token_iterator, start_symbol='jsonpath'):
4040 module_name = os .path .splitext (os .path .split (__file__ )[1 ])[0 ]
4141 except :
4242 module_name = __name__
43-
43+
4444 parsing_table_module = '_' .join ([module_name , start_symbol , 'parsetab' ])
4545
4646 # And we regenerate the parse table every time; it doesn't actually take that long!
@@ -55,7 +55,7 @@ def parse_token_stream(self, token_iterator, start_symbol='jsonpath'):
5555 return new_parser .parse (lexer = IteratorToTokenStream (token_iterator ))
5656
5757 # ===================== PLY Parser specification =====================
58-
58+
5959 precedence = [
6060 ('left' , ',' ),
6161 ('left' , 'DOUBLEDOT' ),
@@ -66,10 +66,10 @@ def parse_token_stream(self, token_iterator, start_symbol='jsonpath'):
6666 ]
6767
6868 def p_error (self , t ):
69- raise Exception ('Parse error at %s:%s near token %s (%s)' % (t .lineno , t .col , t .value , t .type ))
69+ raise Exception ('Parse error at %s:%s near token %s (%s)' % (t .lineno , t .col , t .value , t .type ))
7070
7171 def p_jsonpath_binop (self , p ):
72- """jsonpath : jsonpath '.' jsonpath
72+ """jsonpath : jsonpath '.' jsonpath
7373 | jsonpath DOUBLEDOT jsonpath
7474 | jsonpath WHERE jsonpath
7575 | jsonpath '|' jsonpath
@@ -134,7 +134,7 @@ def p_jsonpath_parens(self, p):
134134
135135 # Because fields in brackets cannot be '*' - that is reserved for array indices
136136 def p_fields_or_any (self , p ):
137- """fields_or_any : fields
137+ """fields_or_any : fields
138138 | '*' """
139139 if p [1 ] == '*' :
140140 p [0 ] = ['*' ]
@@ -165,7 +165,7 @@ def p_maybe_int(self, p):
165165 """maybe_int : NUMBER
166166 | empty"""
167167 p [0 ] = p [1 ]
168-
168+
169169 def p_empty (self , p ):
170170 'empty :'
171171 p [0 ] = None
0 commit comments