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

inclarity in threaded lexer docs leads to confusing failure #227

Open
xplat opened this issue Mar 6, 2022 · 3 comments
Open

inclarity in threaded lexer docs leads to confusing failure #227

xplat opened this issue Mar 6, 2022 · 3 comments

Comments

@xplat
Copy link

xplat commented Mar 6, 2022

https://www.haskell.org/happy/doc/html/sec-monads.html#sec-lexers states that

is the name of the lexical analyser function, and is a token that is to be treated as the end of file.

I had created a token named 'eof' under %token and set to eof. This seemed to work, but when I finished the rest of the grammar to a compiling state, it would immediately fail at the first token. This is because eof was taken as a variable pattern that matched everything, so everything was considered an end of file. The documentation could stand to be louder that this is a Haskell pattern matching the token type, and not the name of a token.

Cc: @cartazio

@cartazio
Copy link

cartazio commented Mar 6, 2022

@cartazio
Copy link

cartazio commented Mar 6, 2022

So the second thing will be used In pattern matching position so it needs to be a constructor or pattern synonym (I’m assuming a pattern synonym is possible?)

@xplat
Copy link
Author

xplat commented Mar 6, 2022

Yes

%lexer { lexer } { TokenEOF }
is how it should actually be done ...

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