Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
For an example, see https://ro-che.info/articles/2015-01-02-lexical-analysis
Documentation
:: RE Char token | regular expression for tokens |
-> RE Char () | regular expression for whitespace and comments |
-> String | source file name (used in locations) |
-> String | source text |
-> [L token] |
The lexer.
In case of a lexical error, throws the LexicalError
exception.
This may seem impure compared to using Either
, but it allows to
consume the token list lazily.
Both token and whitespace regexes consume as many characters as possible (the maximal munch rule). When a regex returns without consuming any characters, a lexical error is signaled.
data LexicalError Source
The lexical error exception