Skip to content

Commit

Permalink
more lenient interpretation of .times expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
jrudolph committed Sep 7, 2021
1 parent bce2bc2 commit 015e863
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,7 @@ trait OpTreeContext[OpTreeCtx <: ParserMacros.ParserContext] {
if (i <= 0) c.abort(base.pos, "`x` in `x.times` must be positive")
else if (i == 1) rule
else Times(rule, q"val min, max = $n", collector, separator)
case x @ (Ident(_) | Select(_, _)) => Times(rule, q"val min = $n; val max = min", collector, separator)
case _ => c.abort(n.pos, "Invalid int base expression for `.times(...)`: " + n)
case i => Times(rule, q"val min = $i; val max = min", collector, separator)
}
case q"$a.this.range2NTimes($r)" =>
r match {
Expand All @@ -434,9 +433,8 @@ trait OpTreeContext[OpTreeCtx <: ParserMacros.ParserContext] {
case _ =>
}
Times(rule, q"val min = $mn; val max = $mx", collector, separator)
case x @ (Ident(_) | Select(_, _)) =>
case r =>
Times(rule, q"val r = $r; val min = r.start; val max = r.end", collector, separator)
case _ => c.abort(r.pos, "Invalid range base expression for `.times(...)`: " + r)
}
case _ => c.abort(base.pos, "Invalid base expression for `.times(...)`: " + base)
}
Expand Down

0 comments on commit 015e863

Please sign in to comment.