Agda-2.5.2: A dependently typed functional programming language and proof assistant

Safe Haskell | None
Language | Haskell2010

Agda.Syntax.Parser.Alex

Contents

- Alex requirements
- Lex actions
- Monad operations

Description

This module defines the things required by Alex and some other Alex related things.

Synopsis

- data AlexInput = AlexInput {
  - lexSrcFile :: !SrcFile
  - lexPos :: !PositionWithoutFile
  - lexInput :: String
  - lexPrevChar :: !Char
  }
- lensLexInput :: Lens' String AlexInput
- alexInputPrevChar :: AlexInput -> Char
- alexGetChar :: AlexInput -> Maybe (Char, AlexInput)
- alexGetByte :: AlexInput -> Maybe (Word8, AlexInput)
- type LexAction r = PreviousInput -> CurrentInput -> TokenLength -> Parser r
- type LexPredicate = ([LexState], ParseFlags) -> PreviousInput -> TokenLength -> CurrentInput -> Bool
- (.&&.) :: LexPredicate -> LexPredicate -> LexPredicate
- (.||.) :: LexPredicate -> LexPredicate -> LexPredicate
- not' :: LexPredicate -> LexPredicate
- type PreviousInput = AlexInput
- type CurrentInput = AlexInput
- type TokenLength = Int
- getLexInput :: Parser AlexInput
- setLexInput :: AlexInput -> Parser ()

# Alex requirements

data AlexInput #

This is what the lexer manipulates.

Constructors

AlexInput |
Fields lexSrcFile :: !SrcFile File. lexPos :: !PositionWithoutFile Current position. lexInput :: String Current input. lexPrevChar :: !Char Previously read character.

lensLexInput :: Lens' String AlexInput #

A lens for `lexInput`.

alexInputPrevChar :: AlexInput -> Char #

Get the previously lexed character. Same as `lexPrevChar`. Alex needs this to be defined to handle "patterns with a left-context".

alexGetChar :: AlexInput -> Maybe (Char, AlexInput) #

Lex a character. No surprises.

This function is used by Alex 2.

alexGetByte :: AlexInput -> Maybe (Word8, AlexInput) #

A variant of `alexGetChar`.

This function is used by Alex 3.

# Lex actions

type LexAction r = PreviousInput -> CurrentInput -> TokenLength -> Parser r #

In the lexer, regular expressions are associated with lex actions who's task it is to construct the tokens.

type LexPredicate = ([LexState], ParseFlags) -> PreviousInput -> TokenLength -> CurrentInput -> Bool #

Sometimes regular expressions aren't enough. Alex provides a way to do arbitrary computations to see if the input matches. This is done with a lex predicate.

(.&&.) :: LexPredicate -> LexPredicate -> LexPredicate #

Conjunction of `LexPredicate`s.

(.||.) :: LexPredicate -> LexPredicate -> LexPredicate #

Disjunction of `LexPredicate`s.

not' :: LexPredicate -> LexPredicate #

Negation of `LexPredicate`s.

type PreviousInput = AlexInput #

type CurrentInput = AlexInput #

type TokenLength = Int #

# Monad operations

getLexInput :: Parser AlexInput #

setLexInput :: AlexInput -> Parser () #