Skip to content

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

@james64

Description

@james64

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[_] => " " ~ "#".? }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions