-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Simple Lexer Creation
--
-- This package provides the tools to create a simple lexer.
@package hlex
@version 1.0.0
-- | Tools needed to create a Lexer from a lexical Grammar.
module Hlex
-- | Lexical grammar made up of GrammarRules.
--
-- The order is important. The Lexer will apply each
-- GrammarRule rule in the order listed.
type Grammar token = [GrammarRule token]
-- | These are the individual rules that make up a Grammar.
--
-- Takes a POSIX regular expression then converts it to a token or
-- skips it.
data GrammarRule token
-- | Skips over any matches.
Skip :: String -> GrammarRule token
-- | Takes a function that converts the matched string to a token.
Tokenize :: String -> (String -> token) -> GrammarRule token
-- | Converts any regular expression matches to a given token.
JustToken :: String -> token -> GrammarRule token
-- | Returns an error with a message when a match occurs.
Error :: String -> String -> GrammarRule token
-- | Converts a string into a list of tokens. If the string does not follow
-- the Lexer's Grammar a LexException will be returned.
type Lexer token = String -> Either LexException [token]
-- | Exception thrown when a Lexer encounters an error when lexxing
-- a string.
data LexException
-- | Exception thrown when a substring cannot be matched.
UnmatchedException :: Int -> Int -> String -> LexException
-- | Exception thrown when a macth is found on the Error
-- GrammarRule.
MatchedException :: Int -> Int -> String -> String -> LexException
-- | Takes a given Grammar and turns it into a Lexer.
hlex :: Grammar token -> Lexer token
instance GHC.Classes.Eq Hlex.LexException
instance GHC.Show.Show Hlex.LexException
instance GHC.Read.Read Hlex.LexException