alex-tools-0.6.1: A set of functions for a common use case of Alex.
Safe HaskellSafe-Inferred
LanguageHaskell2010

AlexToolsBin

Synopsis

Lexer Basics

initialInput Source #

Arguments

:: Text

Where the text came from

-> ByteString

The text to lex

-> Input 

Prepare the text for lexing.

data Input Source #

Information about the lexer's input.

Constructors

Input 

Fields

inputFile :: Input -> Text Source #

The file/thing for the current position.

data Lexeme t Source #

Constructors

Lexeme 

Instances

Instances details
HasRange (Lexeme t) Source # 
Instance details

Defined in AlexToolsBin

Show t => Show (Lexeme t) Source # 
Instance details

Defined in AlexToolsBin

Methods

showsPrec :: Int -> Lexeme t -> ShowS #

show :: Lexeme t -> String #

showList :: [Lexeme t] -> ShowS #

NFData t => NFData (Lexeme t) Source # 
Instance details

Defined in AlexToolsBin

Methods

rnf :: Lexeme t -> () #

Eq t => Eq (Lexeme t) Source # 
Instance details

Defined in AlexToolsBin

Methods

(==) :: Lexeme t -> Lexeme t -> Bool #

(/=) :: Lexeme t -> Lexeme t -> Bool #

data SourcePos Source #

Constructors

SourcePos 

Fields

Instances

Instances details
HasRange SourcePos Source # 
Instance details

Defined in AlexToolsBin

Show SourcePos Source # 
Instance details

Defined in AlexToolsBin

NFData SourcePos Source # 
Instance details

Defined in AlexToolsBin

Methods

rnf :: SourcePos -> () #

Eq SourcePos Source # 
Instance details

Defined in AlexToolsBin

startPos Source #

Arguments

:: Text

Name of file/thing containing this

-> SourcePos 

prevPos :: SourcePos -> SourcePos Source #

Move one position back. Assumes that newlines use a single bytes.

This function is intended to be used when starting the lexing somewhere in the middle of the input, for example, if we are implementing a quasi quoter, and the previous part of the input is not in our language.

data SourceRange Source #

A range in the source code.

Constructors

SourceRange 

Instances

Instances details
HasRange SourceRange Source # 
Instance details

Defined in AlexToolsBin

Show SourceRange Source # 
Instance details

Defined in AlexToolsBin

NFData SourceRange Source # 
Instance details

Defined in AlexToolsBin

Methods

rnf :: SourceRange -> () #

Eq SourceRange Source # 
Instance details

Defined in AlexToolsBin

prettySourcePos :: SourcePos -> String Source #

Pretty print the source position without the file name.

prettySourceRange :: SourceRange -> String Source #

Pretty print the range, without the file name

prettySourcePosLong :: SourcePos -> String Source #

Pretty print the source position, including the file name.

prettySourceRangeLong :: SourceRange -> String Source #

Pretty print the range, including the file name.

class HasRange t where Source #

Methods

range :: t -> SourceRange Source #

Instances

Instances details
HasRange SourcePos Source # 
Instance details

Defined in AlexToolsBin

HasRange SourceRange Source # 
Instance details

Defined in AlexToolsBin

HasRange (Lexeme t) Source # 
Instance details

Defined in AlexToolsBin

(HasRange a, HasRange b) => HasRange (Either a b) Source # 
Instance details

Defined in AlexToolsBin

Methods

range :: Either a b -> SourceRange Source #

(<->) :: (HasRange a, HasRange b) => a -> b -> SourceRange Source #

moveSourcePos :: SourcePos -> SourcePos Source #

Update a SourcePos for a particular matched character

Writing Lexer Actions

newtype Action s a Source #

An action to be taken when a regular expression matchers.

Constructors

A 

Fields

Instances

Instances details
Applicative (Action s) Source # 
Instance details

Defined in AlexToolsBin

Methods

pure :: a -> Action s a #

(<*>) :: Action s (a -> b) -> Action s a -> Action s b #

liftA2 :: (a -> b -> c) -> Action s a -> Action s b -> Action s c #

(*>) :: Action s a -> Action s b -> Action s b #

(<*) :: Action s a -> Action s b -> Action s a #

Functor (Action s) Source # 
Instance details

Defined in AlexToolsBin

Methods

fmap :: (a -> b) -> Action s a -> Action s b #

(<$) :: a -> Action s b -> Action s a #

Monad (Action s) Source # 
Instance details

Defined in AlexToolsBin

Methods

(>>=) :: Action s a -> (a -> Action s b) -> Action s b #

(>>) :: Action s a -> Action s b -> Action s b #

return :: a -> Action s a #

Lexemes

lexeme :: t -> Action s [Lexeme t] Source #

Use the token and the current match to construct a lexeme.

matchLength :: Action s Int Source #

The number of characters in the matching input.

matchRange :: Action s SourceRange Source #

Get the range for the matching input.

matchBytes :: Action s ByteString Source #

Get the text associated with the matched input.

Manipulating the lexer's state

getLexerState :: Action s s Source #

Acces the curent state of the lexer.

setLexerState :: s -> Action s () Source #

Change the state of the lexer.

Access to the lexer's input

startInput :: Action s Input Source #

Acces the input just before the regular expression started matching.

endInput :: Action s Input Source #

Acces the input just after the regular expression that matched.

Interface with Alex

makeLexer :: ExpQ Source #

Generate a function to use an Alex lexer. The expression is of type LexerConfig s t -> Input -> [Lexeme t]

data LexerConfig s t Source #

Lexer configuration.

Constructors

LexerConfig 

Fields

simpleLexer :: LexerConfig () t Source #

A lexer that uses no lexer-modes, and does not emit anything at the end of the file.

data Word8 #

8-bit unsigned integer type

Instances

Instances details
Bits Word8

Since: base-2.1

Instance details

Defined in GHC.Word

FiniteBits Word8

Since: base-4.6.0.0

Instance details

Defined in GHC.Word

Bounded Word8

Since: base-2.1

Instance details

Defined in GHC.Word

Enum Word8

Since: base-2.1

Instance details

Defined in GHC.Word

Ix Word8

Since: base-2.1

Instance details

Defined in GHC.Word

Num Word8

Since: base-2.1

Instance details

Defined in GHC.Word

Read Word8

Since: base-2.1

Instance details

Defined in GHC.Read

Integral Word8

Since: base-2.1

Instance details

Defined in GHC.Word

Real Word8

Since: base-2.1

Instance details

Defined in GHC.Word

Methods

toRational :: Word8 -> Rational #

Show Word8

Since: base-2.1

Instance details

Defined in GHC.Word

Methods

showsPrec :: Int -> Word8 -> ShowS #

show :: Word8 -> String #

showList :: [Word8] -> ShowS #

NFData Word8 
Instance details

Defined in Control.DeepSeq

Methods

rnf :: Word8 -> () #

Eq Word8

Since: base-2.1

Instance details

Defined in GHC.Word

Methods

(==) :: Word8 -> Word8 -> Bool #

(/=) :: Word8 -> Word8 -> Bool #

Ord Word8

Since: base-2.1

Instance details

Defined in GHC.Word

Methods

compare :: Word8 -> Word8 -> Ordering #

(<) :: Word8 -> Word8 -> Bool #

(<=) :: Word8 -> Word8 -> Bool #

(>) :: Word8 -> Word8 -> Bool #

(>=) :: Word8 -> Word8 -> Bool #

max :: Word8 -> Word8 -> Word8 #

min :: Word8 -> Word8 -> Word8 #

Lift Word8 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Quote m => Word8 -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => Word8 -> Code m Word8 #