Skip to content
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

(chibi parse): Inaccurate line number information in parse-failure #876

Open
nmeum opened this issue Dec 14, 2022 · 0 comments
Open

(chibi parse): Inaccurate line number information in parse-failure #876

nmeum opened this issue Dec 14, 2022 · 0 comments

Comments

@nmeum
Copy link
Contributor

nmeum commented Dec 14, 2022

Consider the following chibi program:

(import (scheme base)
        (scheme write)
        (srfi 14)
        (chibi parse))

(define parse-line
  (parse-seq
    (parse-repeat+ (parse-char char-set:digit))
    (parse-char char-set:blank)
    (parse-repeat+ (parse-char char-set:letter))
    parse-end-of-line))

(let ((s (string->parse-stream "42foobar")))
  (call-with-parse
    parse-line
    s
    0
    (lambda (r s i fk)
      (display "success: ")
      (display r)
      (newline))
    parse-failure))

This outputs the following error:

ERROR: incomplete parse at: (0 2 "42f" "failed char pred")
  called from <anonymous> on line 1292 of file /usr/share/chibi/init-7.scm
  called from <anonymous> on line 821 of file /usr/share/chibi/init-7.scm

Since the car of the list in the error message is the line number, I would have expected the output to be:

ERROR: incomplete parse at: (1 2 "42f" "failed char pred")

Since the error occurs on the first line of input. However, it seems that chibi-scheme starts counting line numbers at zero (which I would argue is at the very least unconventional). Is it intentional that line numbers start at zero?

@nmeum nmeum changed the title (chibi parse): Inaccurate location information in parse-failure (chibi parse): Inaccurate line number information in parse-failure Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant