New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UberBuffer index -1 must be between 0 and 1 #208

Closed
james64 opened this Issue Dec 16, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@james64
Copy link

james64 commented Dec 16, 2018

I am getting error in title. Working example below. This is probably related to #135 because both whitespaceApi and iterator parsing are involved. I use version 2.0.5

import fastparse._

object SortOfMinimalExample extends App {

  def p3[_:P] : P[Unit] = {
    import NoWhitespace._
    "a" ~ " ".rep ~/ "b"
  }

  def p2[_:P] : P[Unit] = {
    import CustomWhitespace._
    p3.rep(sep = "\n".rep)
  }

  def p1[_:P] : P[Unit] = {
    import NoWhitespace._
    p2 ~ "]"
  }

  parse("a b ]", p1(_)) // this works
  parse(Seq("a b ]").iterator, p1(_)) // this does not
}

object CustomWhitespace {
  import NoWhitespace._
  implicit val whitespace : P[_] => P[Unit] = { implicit ctx: P[_] => " " ~ "#".? }
}
@lihaoyi

This comment has been minimized.

Copy link
Owner

lihaoyi commented Dec 18, 2018

Slightly more minimized:

@ {
  import fastparse._

  def p3[_:P]: P[Unit] = {
    import NoWhitespace._
    "a" ~ " " ~/ "b"
  }

  def p2[_:P]: P[Unit] = {
    import CustomWhitespace._
    p3.rep() // Note: p3.rep passes!!!
  }

  def p1[_:P]: P[Unit] = {
    import NoWhitespace._
    p2 ~ "]"
  }

  object CustomWhitespace {
    import NoWhitespace._
    implicit val whitespace : P[_] => P[Unit] = { implicit ctx: P[_] => " " ~ " ".?}
  }
  parse(Seq("a b ]").iterator, p1(_)) // boom
  }
@lihaoyi

This comment has been minimized.

Copy link
Owner

lihaoyi commented Dec 18, 2018

This appears to be fixed in my latest dev branch https://github.com/lihaoyi/fastparse/tree/dynamic-aggregation. Unclear what fixed it, but there are a lot of fixes in that branch for various edge cases. I'll see if I can clean it up and publish

@lihaoyi

This comment has been minimized.

Copy link
Owner

lihaoyi commented Dec 19, 2018

Fixed in 2.1.0

@lihaoyi lihaoyi closed this Dec 19, 2018

@james64

This comment has been minimized.

Copy link

james64 commented Dec 19, 2018

I confirm the fix works for me as well. Thanks for quick turnaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment