Skip to content

Commit

Permalink
Fixed exponential grammar bug. Fixes #201.
Browse files Browse the repository at this point in the history
  • Loading branch information
dragostis committed Feb 21, 2018
1 parent 93a9fab commit 37142e7
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions pest_derive/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,13 +463,13 @@ fn generate_expr(expr: Expr) -> Tokens {
state.sequence(#[inline(always)] move |state| {
pos.sequence(#[inline(always)] |pos| {
pos.optional(#[inline(always)] |pos| {
#expr
}).and_then(#[inline(always)] |pos| {
pos.repeat(#[inline(always)] |pos| {
state.sequence(#[inline(always)] move |state| {
pos.sequence(#[inline(always)] |pos| {
self::skip(pos, state).and_then(#[inline(always)] |pos| {
#expr
#expr.and_then(#[inline(always)] |pos| {
pos.repeat(#[inline(always)] |pos| {
state.sequence(#[inline(always)] move |state| {
pos.sequence(#[inline(always)] |pos| {
self::skip(pos, state).and_then(#[inline(always)] |pos| {
#expr
})
})
})
})
Expand Down Expand Up @@ -857,18 +857,20 @@ mod tests {
self::a(pos, state).or_else(#[inline(always)] |pos| {
state.sequence(#[inline(always)] move |state| {
pos.sequence(#[inline(always)] |pos| {
pos.match_range( 'a' .. 'b' ).and_then(#[inline(always)] |pos| {
pos.match_range('a'..'b').and_then(#[inline(always)] |pos| {
self::skip(pos, state)
}).and_then(#[inline(always)] |pos| {
state.lookahead(false, #[inline(always)] move |state| {
pos.lookahead(false, #[inline(always)] |pos| {
state.sequence(#[inline(always)] move |state| {
pos.sequence(#[inline(always)] |pos| {
pos.optional(#[inline(always)] |pos| {
pos.match_insensitive("b")
}).and_then(#[inline(always)] |pos| {
pos.repeat(#[inline(always)] |pos| {
#sequence
pos.match_insensitive(
"b"
).and_then(#[inline(always)] |pos| {
pos.repeat(#[inline(always)] |pos| {
#sequence
})
})
})
})
Expand All @@ -888,9 +890,9 @@ mod tests {
#[inline(always)] |pos| {
pos.match_string("d")
}
)
}).and_then(#[inline(always)] |pos| {
#repeat
).and_then(#[inline(always)] |pos| {
#repeat
})
})
})
})
Expand Down

0 comments on commit 37142e7

Please sign in to comment.