Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
fast unicode-enabled quasiquoted lexers for Haskell (work in progress)
Haskell
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Text
.gitignore
LICENSE
Main.hs
README.markdown
Setup.lhs
luthor.cabal

README.markdown

luthor

fast unicode-enabled lexers for Haskell, based on Alex, and written in the form of quasiquoters to avoid a separate build step.

Example:

import Text.Luthor

data Token 
    = Let
    | In
    | Sym Char
    | Var String
    | Int Int
    deriving (Eq,Show)

tokenLexer :: Lexer Token
tokenLexer = [$lexer|
    $identStart = [A-Za-z0-9]         -- set macros
    $identBody  = [${identStart} _ ']
    @var = $identStart ${identBody}*  -- regex macros

    tokens :-

    \s+                 ;              -- perl shortcuts
    "--".*              ;
    let                 { \s -> Let }
    in                  { \s -> In }
    \p{Digit}+          { Int . read } -- posix classes
    \p{Symbol}          { Sym . head } -- unicode classes
    @var                { Var } |]

scanTokens :: String -> [Token]
scanTokens = scan tokenLexer
Something went wrong with that request. Please try again.