uulib-0.9.24: Haskell Utrecht Tools Library

Safe Haskell | Safe-Inferred
Language | Haskell98

UU.Parsing.MachineInterface

Synopsis

- class InputState state s pos | state -> s, state -> pos where
  - splitStateE :: state -> Either' state s
  - splitState :: state -> (# s, state #)
  - getPosition :: state -> pos
  - reportError :: Message s pos -> state -> state
  - insertSymbol :: s -> state -> state
  - deleteSymbol :: s -> state -> state
- class OutputState r where
  - acceptR :: v -> rest -> r v rest
  - nextR :: (a -> rest -> rest') -> (b -> a) -> r b rest -> rest'
- class Symbol s where
  - deleteCost :: s -> Int#
  - symBefore :: s -> s
  - symAfter :: s -> s
- data Either' state s
  - = Left' !s state
  - | Right' state
- data Steps val s p
  - = forall a. OkVal (a -> val) (Steps a s p)
  - | Ok {
    - rest :: Steps val s p
    }
  - | Cost {
    - costing :: Int#
    - rest :: Steps val s p
    }
  - | StRepair {
    - costing :: Int#
    - m :: !(Message s p)
    - rest :: Steps val s p
    }
  - | Best (Steps val s p) (Steps val s p) (Steps val s p)
  - | NoMoreSteps val
- data Action s
  - = Insert s
  - | Delete s
  - | Other String
- val :: (a -> b) -> Steps a s p -> Steps b s p
- evalSteps :: Steps a s p -> a
- getMsgs :: Steps a s p -> [Message s p]
- data Message sym pos = Msg (Expecting sym) !pos (Action sym)
- data Expecting s
  - = ESym (SymbolR s)
  - | EStr String
  - | EOr [Expecting s]
  - | ESeq [Expecting s]
- data SymbolR s
  - = Range !s !s
  - | EmptyR
- mk_range :: Ord s => s -> s -> SymbolR s
- symInRange :: Ord a => SymbolR a -> a -> Bool
- symRS :: Ord a => SymbolR a -> a -> Ordering
- except :: (Foldable t, Ord a, Symbol a) => SymbolR a -> t a -> [SymbolR a]
- usererror :: [Char] -> a
- systemerror :: [Char] -> [Char] -> a

# Documentation

class InputState state s pos | state -> s, state -> pos where Source #

The `InputState` class contains the interface that the AnaParser parsers expect for the input. A minimal complete instance definition consists of `splitStateE`, `splitState` and `getPosition`.

Minimal complete definition

splitStateE, splitState, getPosition

Methods

splitStateE :: state -> Either' state s Source #

Splits the state in a strict variant of `Either`, with `Left'` if a symbol can be split off and `Right'` if none can

splitState :: state -> (# s, state #) Source #

Splits the state in the first symbol and the remaining state

getPosition :: state -> pos Source #

Gets the current position in the input

reportError :: Message s pos -> state -> state Source #

Reports an error

insertSymbol :: s -> state -> state Source #

Modify the state as the result of inserting a symbol `s` in the input. The symbol that has already been considered as having been inserted is passed. It should normally not be added to the state.

deleteSymbol :: s -> state -> state Source #

Modify the state as the result of deleting a symbol `s` from the input. The symbol that has already been deleted from the input state is passed. It should normally not be deleted from the state.

#### Instances

Instances details

InputState Input Char Pos Source # |
Instance details Defined in UU.Parsing.CharParser Methods splitStateE :: Input -> Either' Input Char Source # splitState :: Input -> (# Char, Input #) Source # getPosition :: Input -> Pos Source # reportError :: Message Char Pos -> Input -> Input Source # insertSymbol :: Char -> Input -> Input Source # deleteSymbol :: Char -> Input -> Input Source #
InputState [s] s (Maybe s) Source # |
Instance details Defined in UU.Parsing.Interface Methods splitStateE :: [s] -> Either' [s] s Source # splitState :: [s] -> (# s, [s] #) Source # getPosition :: [s] -> Maybe s Source # reportError :: Message s (Maybe s) -> [s] -> [s] Source # insertSymbol :: s -> [s] -> [s] Source # deleteSymbol :: s -> [s] -> [s] Source #
InputState inp s p => InputState (inp, state) s p Source # |

Instance details

Defined in UU.Parsing.StateParser

Methods

splitStateE :: (inp, state) -> Either' (inp, state) s Source #

splitState :: (inp, state) -> (# s, (inp, state) #) Source #

getPosition :: (inp, state) -> p Source #

reportError :: Message s p -> (inp, state) -> (inp, state) Source #

insertSymbol :: s -> (inp, state) -> (inp, state) Source #

deleteSymbol :: s -> (inp, state) -> (inp, state) Source #

InputState inp s p => InputState (OffsideInput inp s p) (OffsideSymbol s) p Source # |

Instance details

Defined in UU.Parsing.Offside

Methods

splitStateE :: OffsideInput inp s p -> Either' (OffsideInput inp s p) (OffsideSymbol s) Source #

splitState :: OffsideInput inp s p -> (# OffsideSymbol s, OffsideInput inp s p #) Source #

getPosition :: OffsideInput inp s p -> p Source #

reportError :: Message (OffsideSymbol s) p -> OffsideInput inp s p -> OffsideInput inp s p Source #

insertSymbol :: OffsideSymbol s -> OffsideInput inp s p -> OffsideInput inp s p Source #

deleteSymbol :: OffsideSymbol s -> OffsideInput inp s p -> OffsideInput inp s p Source #

class OutputState r where Source #

Methods

acceptR :: v -> rest -> r v rest Source #

nextR :: (a -> rest -> rest') -> (b -> a) -> r b rest -> rest' Source #

#### Instances

Instances details

OutputState Pair Source # |
Instance details Defined in UU.Parsing.Interface Methods acceptR :: v -> rest -> Pair v rest Source # nextR :: (a -> rest -> rest') -> (b -> a) -> Pair b rest -> rest' Source #

class Symbol s where Source #

Minimal complete definition

Nothing

Methods

deleteCost :: s -> Int# Source #

symBefore :: s -> s Source #

symAfter :: s -> s Source #

#### Instances

Instances details

Symbol Char Source # |
Instance details Defined in UU.Parsing.CharParser Methods deleteCost :: Char -> Int# Source # symBefore :: Char -> Char Source # symAfter :: Char -> Char Source #
Symbol s => Symbol (OffsideSymbol s) Source # |
Instance details Defined in UU.Parsing.Offside Methods deleteCost :: OffsideSymbol s -> Int# Source # symBefore :: OffsideSymbol s -> OffsideSymbol s Source # symAfter :: OffsideSymbol s -> OffsideSymbol s Source #
Symbol (GenToken key tp val) Source # |
Instance details Defined in UU.Scanner.GenTokenSymbol Methods deleteCost :: GenToken key tp val -> Int# Source # symBefore :: GenToken key tp val -> GenToken key tp val Source # symAfter :: GenToken key tp val -> GenToken key tp val Source #

data Either' state s Source #

Constructors

Left' !s state |
Right' state |

data Steps val s p Source #

Constructors

forall a. OkVal (a -> val) (Steps a s p) |
Ok |

Fields

- rest :: Steps val s p

Cost |

Fields

- costing :: Int#
- rest :: Steps val s p

StRepair |

Fields

- costing :: Int#
- m :: !(Message s p)
- rest :: Steps val s p

Best (Steps val s p) (Steps val s p) (Steps val s p) |
NoMoreSteps val |

data Action s Source #

Constructors

Insert s |
Delete s |
Other String |

#### Instances

Instances details

Show s => Show (Action s) Source # |
Instance details Defined in UU.Parsing.MachineInterface Methods showsPrec :: Int -> Action s -> ShowS Source # show :: Action s -> String Source # showList :: [Action s] -> ShowS Source #

val :: (a -> b) -> Steps a s p -> Steps b s p Source #

evalSteps :: Steps a s p -> a Source #

getMsgs :: Steps a s p -> [Message s p] Source #

data Message sym pos Source #

Constructors

Msg (Expecting sym) !pos (Action sym) |

#### Instances

Instances details

(Eq s, Show s, Show p) => Show (Message s p) Source # |
Instance details Defined in UU.Parsing.MachineInterface Methods showsPrec :: Int -> Message s p -> ShowS Source # show :: Message s p -> String Source # showList :: [Message s p] -> ShowS Source #

data Expecting s Source #

Constructors

ESym (SymbolR s) |
EStr String |
EOr [Expecting s] |
ESeq [Expecting s] |

#### Instances

Instances details

(Eq s, Show s) => Show (Expecting s) Source # |
Instance details Defined in UU.Parsing.MachineInterface Methods showsPrec :: Int -> Expecting s -> ShowS Source # show :: Expecting s -> String Source # showList :: [Expecting s] -> ShowS Source #
Eq s => Eq (Expecting s) Source # |
Instance details Defined in UU.Parsing.MachineInterface Methods (==) :: Expecting s -> Expecting s -> Bool Source # (/=) :: Expecting s -> Expecting s -> Bool Source #
Ord s => Ord (Expecting s) Source # |

Instance details

Defined in UU.Parsing.MachineInterface

Methods

compare :: Expecting s -> Expecting s -> Ordering Source #

(<) :: Expecting s -> Expecting s -> Bool Source #

(<=) :: Expecting s -> Expecting s -> Bool Source #

(>) :: Expecting s -> Expecting s -> Bool Source #

(>=) :: Expecting s -> Expecting s -> Bool Source #

max :: Expecting s -> Expecting s -> Expecting s Source #

min :: Expecting s -> Expecting s -> Expecting s Source #

data SymbolR s Source #

Constructors

Range !s !s |
EmptyR |

#### Instances

Instances details

(Eq s, Show s) => Show (SymbolR s) Source # |
Instance details Defined in UU.Parsing.MachineInterface Methods showsPrec :: Int -> SymbolR s -> ShowS Source # show :: SymbolR s -> String Source # showList :: [SymbolR s] -> ShowS Source #
Eq s => Eq (SymbolR s) Source # |
Instance details Defined in UU.Parsing.MachineInterface Methods (==) :: SymbolR s -> SymbolR s -> Bool Source # (/=) :: SymbolR s -> SymbolR s -> Bool Source #
Ord s => Ord (SymbolR s) Source # |

Instance details

Defined in UU.Parsing.MachineInterface

Methods

compare :: SymbolR s -> SymbolR s -> Ordering Source #

(<) :: SymbolR s -> SymbolR s -> Bool Source #

(<=) :: SymbolR s -> SymbolR s -> Bool Source #

(>) :: SymbolR s -> SymbolR s -> Bool Source #

(>=) :: SymbolR s -> SymbolR s -> Bool Source #

max :: SymbolR s -> SymbolR s -> SymbolR s Source #

min :: SymbolR s -> SymbolR s -> SymbolR s Source #

mk_range :: Ord s => s -> s -> SymbolR s Source #

symInRange :: Ord a => SymbolR a -> a -> Bool Source #

symRS :: Ord a => SymbolR a -> a -> Ordering Source #

except :: (Foldable t, Ord a, Symbol a) => SymbolR a -> t a -> [SymbolR a] Source #

usererror :: [Char] -> a Source #

systemerror :: [Char] -> [Char] -> a Source #