Skip to content

Commit

Permalink
Simplify fold-parsing code.
Browse files Browse the repository at this point in the history
  • Loading branch information
01mf02 committed Nov 14, 2024
1 parent c878434 commit 0a93877
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions jaq-core/src/load/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ pub type Result<'s, 't, T> = core::result::Result<T, TError<'t, &'s str>>;
pub struct Parser<'s, 't> {
i: core::slice::Iter<'t, Token<&'s str>>,
e: Vec<TError<'t, &'s str>>,
/// names of fold-like filters, e.g. "reduce" and "foreach"
fold: &'s [&'s str],
}

/// Function from value to stream of values, such as `.[] | add / length`.
Expand Down Expand Up @@ -223,7 +221,6 @@ impl<'s, 't> Parser<'s, 't> {
Self {
i: i.iter(),
e: Vec::new(),
fold: &["reduce", "foreach"],
}
}

Expand Down Expand Up @@ -524,7 +521,7 @@ impl<'s, 't> Parser<'s, 't> {
Term::Label(x, Box::new(tm))
}
Some(Token("break", _)) => Term::Break(self.var()?),
Some(Token(fold, Tok::Word)) if self.fold.contains(fold) => {
Some(Token(fold @ ("reduce" | "foreach"), _)) => {
let xs = self.atom()?;
self.just("as")?;
let x = self.pattern()?;
Expand Down

0 comments on commit 0a93877

Please sign in to comment.