haskell / alex

A lexical analyser generator for Haskell
https://hackage.haskell.org/package/alex
BSD 3-Clause "New" or "Revised" License
298 stars 82 forks source link

Fix #180: example tiger.x: correct position of lexed string literal #226

Closed andreasabel closed 1 year ago

andreasabel commented 1 year ago

Fix #180: example tiger.x: correct position of lexed string literal.

Previously, we would get e.g.

Lexeme class=STRING "Hello, world!" posn=1:19 string="\""

where the position points at the closing double quotes which are also errorneously returned as lexed input.

Now, we produce

Lexeme class=STRING "Hello, world!" posn=1:5

with the correct starting position yet no information about the lexed input (Nothing).

To produce the lexed input, one needs more information in the lexer state.
Not worth fixing, I deem, this is good enough as is as an example for Alex.