Skip to content

Commit 62a5c54

Browse files
committed
Incorporate new JEP-9 tokens into new lexer
Re-adds support for the 'not' token (!) and the 'and' token ('&&'). cc @mtdowling
1 parent 4bfed53 commit 62a5c54

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

jmespath/lexer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ class Lexer(object):
1818
',': 'comma',
1919
':': 'colon',
2020
'@': 'current',
21-
'&': 'expref',
2221
'(': 'lparen',
2322
')': 'rparen',
2423
'{': 'lbrace',
25-
'}': 'rbrace'
24+
'}': 'rbrace',
2625
}
2726

2827
def tokenize(self, expression):
@@ -60,6 +59,8 @@ def tokenize(self, expression):
6059
yield self._consume_raw_string_literal()
6160
elif self._current == '|':
6261
yield self._match_or_else('|', 'or', 'pipe')
62+
elif self._current == '&':
63+
yield self._match_or_else('&', 'and', 'expref')
6364
elif self._current == '`':
6465
yield self._consume_literal()
6566
elif self._current in self.START_NUMBER:
@@ -76,7 +77,7 @@ def tokenize(self, expression):
7677
elif self._current == '>':
7778
yield self._match_or_else('=', 'gte', 'gt')
7879
elif self._current == '!':
79-
yield self._match_or_else('=', 'ne', 'unknown')
80+
yield self._match_or_else('=', 'ne', 'not')
8081
elif self._current == '=':
8182
yield self._match_or_else('=', 'eq', 'unknown')
8283
else:

0 commit comments

Comments
 (0)