We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4a5df2d commit 2750076Copy full SHA for 2750076
jaq-core/src/load/lex.rs
@@ -291,15 +291,16 @@ impl<'a> Lexer<&'a str> {
291
fn token(&mut self) -> Option<Token<&'a str>> {
292
self.space();
293
294
- let is_op = |c| "|=!<>+-*/%".contains(c);
+ let hd_op = |c| "|=!<>+-*/%".contains(c);
295
+ let tl_op = |c| hd_op(c) && c != '-';
296
297
let mut chars = self.i.chars();
298
let (s, tok) = match chars.next()? {
299
'a'..='z' | 'A'..='Z' | '_' => (self.consumed(1, Self::mod_then_ident), Tok::Word),
300
'$' => (self.consumed(1, Self::ident1), Tok::Var),
301
'@' => (self.consumed(1, Self::ident1), Tok::Fmt),
302
'0'..='9' => (self.consumed(1, Self::num), Tok::Num),
- c if is_op(c) => (self.consumed(1, |lex| lex.trim(is_op)), Tok::Sym),
303
+ c if hd_op(c) => (self.consumed(1, |lex| lex.trim(tl_op)), Tok::Sym),
304
'.' => match chars.next() {
305
Some('.') => (self.take(2), Tok::Sym),
306
Some('a'..='z' | 'A'..='Z' | '_') => (self.consumed(2, Self::ident0), Tok::Sym),
jaq-core/tests/tests.rs
@@ -141,6 +141,8 @@ yields!(atomic_opt, "def x: 0; try x? catch 1", 0);
141
yields!(neg_arr_iter1, "[-[][]]", json!([]));
142
yields!(neg_arr_iter2, "try (-[])[] catch 0", 0);
143
144
+yields!(neg_after_bin, ".+=-1", -1);
145
+
146
yields!(interpolation, r#"1 | "yields \(.+1)!""#, "yields 2!");
147
// this diverges from jq, which yields ["2 2", "3 2", "2 4", "3 4"],
148
// probably due to different order of evaluation addition
0 commit comments