Skip to content

Commit 55e0297

Browse files
PiotrJustynaandreasabel
authored andcommitted
Update words.x
1 parent 99a061d commit 55e0297

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

examples/words.x

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1-
-- run with:
2-
-- alexScanTokens " 123 abc "
3-
-- for example
1+
-- this is intended to be a performance test of an alex-generated lexer
2+
-- * run with /usr/dict/words or equivalent, depending on your os, e.g.:
3+
-- * mac os: /usr/share/dict/words
4+
-- * alpine linux: available as a package
5+
-- (https://pkgs.alpinelinux.org/packages?name=words&branch=edge&repo=&arch=&origin=&flagged=&maintainer=)
6+
-- and when installed, available here: /usr/share/dict/ (the directory contains multiple languages)
7+
-- * to generate lexer:
8+
-- alex words.x
9+
-- * to scan a basic string with the generated lexer using ghci:
10+
-- $ ghci
11+
-- ghci> :l words
12+
-- ghci> alexScanTokens "word1 word2" (produces: ["word1","word2"])
13+
-- * to run the performance test as intended, compile the lexer into an executable and run with:
14+
-- time ./words.bin +RTS -s < /usr/dict/words
415
{
516
module Main (main) where
617
}
@@ -10,7 +21,7 @@ module Main (main) where
1021
words :-
1122

1223
$white+ ;
13-
[A-Za-z0-9\'\-]+ { \s -> "word: " <> s }
24+
[A-Za-z0-9\'\-]+ { \s -> s }
1425
1526
{
1627
main = do

0 commit comments

Comments
 (0)