haskell / haskell/happy

inclarity in threaded lexer docs leads to confusing failure

Open
#227 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
Haskell
Stars
322
Forks
86
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.