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

Failure index for negative lookahead in the wrong place? #169

Closed
lihaoyi opened this Issue Oct 4, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@lihaoyi
Owner

lihaoyi commented Oct 4, 2017

@ import fastparse.all._
import fastparse.all._

@ val p = P( "hello" ~ !"  " ~ AnyChar ~ "world" ).!
p: Parser[String, Char, String] = Capturing(
  Rule("p", ammonite.$sess.cmd1$$$Lambda$1922/1117747481@53abfc07)
)

@ p.parse("hello  world")
res2: Parsed[String, Char, String] = Failure(
  Not(ElemLiteral(' ')),
  7,
  Extra(hello world, [traced - not evaluated])
)

I'd expect the above Failure object to have an index of 5, since "hello" is 5 characters long, and that's where the Not(ElemLiteral(' ')) call tries to parse and fails. However, it is instead 7, which is where the inner ElemLiteral(' ') call parses and succeeds. It should probably be 5 in this case

@lihaoyi lihaoyi closed this Oct 18, 2018

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