File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change 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
4
15
{
5
16
module Main (main) where
6
17
}
@@ -10,7 +21,7 @@ module Main (main) where
10
21
words :-
11
22
12
23
$white+ ;
13
- [A-Za-z0-9 \' \- ]+ { \s -> "word: " <> s }
24
+ [A-Za-z0-9 \' \- ]+ { \s -> s }
14
25
15
26
{
16
27
main = do
You can’t perform that action at this time.
0 commit comments