Skip to content

Update words.x #275

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions examples/words.x
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
-- Performance test; run with input /usr/dict/words, for example
-- this is intended to be a performance test of an alex-generated lexer
-- * run with /usr/dict/words or equivalent, depending on your os, e.g.:
-- * mac os: /usr/share/dict/words
-- * alpine linux: available as a package
-- (https://pkgs.alpinelinux.org/packages?name=words&branch=edge&repo=&arch=&origin=&flagged=&maintainer=)
-- and when installed, available here: /usr/share/dict/ (the directory contains multiple languages)
-- * to generate lexer:
-- alex words.x
-- * to scan a basic string with the generated lexer using ghci:
-- $ ghci
-- ghci> :l words
-- ghci> alexScanTokens "word1 word2" (produces: ["word1","word2"])
-- * to run the performance test as intended, compile the lexer into an executable and run with:
-- time ./words.bin +RTS -s < /usr/dict/words
{
module Main (main) where
}
Expand All @@ -8,7 +21,7 @@ module Main (main) where
words :-

$white+ ;
[A-Za-z0-9\'\-]+ { \s -> () }
[A-Za-z0-9\'\-]+ { \s -> s }

{
main = do
Expand Down