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

Backtracking #2

Open
kisp opened this issue Oct 24, 2023 · 1 comment
Open

Backtracking #2

kisp opened this issue Oct 24, 2023 · 1 comment

Comments

@kisp
Copy link

kisp commented Oct 24, 2023

Hi, I am not sure whether I should expect backtracking to occur.

For instance, in this example

(import lexgen)

(define (err s)
  (print "lexical error on stream: " s)
  (list))

(lex (seq (star (range #\0 #\9)) (char #\2)) err "123")

I get the error

lexical error on stream: ((3 2 1) #!eof)

instead of getting the possible result:

((#\1 #\2) (#\3))
@iraikov
Copy link
Owner

iraikov commented Oct 25, 2023

Hello, thank you for using lexgen. There is no provision for general backtracking, as that usually incurs a significant performance penalty. In principle, the error continuation can be modified to return the unmodified input stream and/or apply alternate lexer functions.

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

2 participants