Skip to content

3 new lexer examples#284

Merged
andreasabel merged 3 commits intohaskell:masterfrom
PiotrJustyna:wyvern-examples
Feb 4, 2026
Merged

3 new lexer examples#284
andreasabel merged 3 commits intohaskell:masterfrom
PiotrJustyna:wyvern-examples

Conversation

@PiotrJustyna
Copy link
Contributor

First of all, thank you for your fantastic work on alex. I keep coming back to this repository.

I recently found myself needing more information from lexing errors, specifically error position in the input. I've been using the basic wrapper, then switched to posn and finally landed on monad. I had a difficult time putting together the full picture of an alex file implementing the monad wrapper and once I finally got it done, I thought my files could help somebody.


Additionally, I made two small improvements/fixes so the examples compile with ghc 9.8.4:

  • import Data.Char (ord) required by examples:
    • haskell.x
    • tiger.x
  • I changed alex location to where my cabal places it. Probably not the most portable thing and something better could be used but it does work and gives the user an idea of where to look for alex: ALEX=../dist-newstyle/build/x86_64-linux/ghc-9.8.4/alex-3.5.4.0/x/alex/build/alex/alex

Copy link
Member

@andreasabel andreasabel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

I tried make ALEX=alex all in the examples directory but it does not build (nor run) your new examples.

One simple fix would be to move your examples out of wyvern/ and prefix these files with wyvern- instead.

@@ -1,4 +1,4 @@
ALEX=../dist/build/alex/alex
ALEX=../dist-newstyle/build/x86_64-linux/ghc-9.8.4/alex-3.5.4.0/x/alex/build/alex/alex
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem very portable nor future proof.
The old setting isn't great either, but at least it works with cabal v1-build independent of the GHC version and OS.
Maybe it is best to port the logic from /tests/Makefile.

@PiotrJustyna
Copy link
Contributor Author

Thank you for reviewing @andreasabel. I applied your feedback and managed to avoid rearranging wyvern files so they are still nicely compartmentalized. Please let me know if you think there's something missing.

Copy link
Member

@andreasabel andreasabel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I can run these examples now as described in the readme, once I built them with cabal exec -- make.

@andreasabel andreasabel added the examples Concerning the examples supplied with Alex label Feb 4, 2026
@andreasabel andreasabel added this to the 3.5.4.1 milestone Feb 4, 2026
@andreasabel andreasabel merged commit 74a9b2b into haskell:master Feb 4, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples Concerning the examples supplied with Alex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants