License | BSD-3-Clause |
---|---|
Maintainer | Jamie Willis |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Extensions |
|
This module contains the primitive operations required by the parsing machinery to work with input.
Since: 1.0.0.0
Synopsis
- class InputPrep input where
- prepare :: rep ~ Rep input => Code input -> Code (InputDependant rep)
- class PositionOps (rep :: TYPE r) where
- class LogOps (rep :: TYPE r) where
- data InputOps (rep :: TYPE r) = InputOps {}
- more :: forall r (rep :: TYPE r). (?ops :: InputOps rep) => Code rep -> Code Bool
- next :: forall r (rep :: TYPE r) a. (?ops :: InputOps rep) => Code rep -> (Code Char -> Code rep -> Code a) -> Code a
- type InputDependant (rep :: TYPE r) = (# rep -> (# Char, rep #), rep -> Bool, rep #)
Documentation
class InputPrep input where Source #
This class is responsible for converting the user's input into a form that parsley can work with efficiently.
Since: 1.0.0.0
prepare :: rep ~ Rep input => Code input -> Code (InputDependant rep) Source #
Given the user's input to the parser, in its original form, this function
distils it first into
, which is parsley's internal representation,
and then produces an Rep
inputInputDependant
containing the core operations.
Since: 1.0.0.0
Instances
InputPrep ByteString Source # | |
Defined in Parsley.Internal.Backend.Machine.InputOps prepare :: forall (rep :: TYPE (RepKind ByteString)). rep ~ Rep ByteString => Code ByteString -> Code (InputDependant rep) Source # | |
InputPrep ByteString Source # | |
Defined in Parsley.Internal.Backend.Machine.InputOps prepare :: forall (rep :: TYPE (RepKind ByteString)). rep ~ Rep ByteString => Code ByteString -> Code (InputDependant rep) Source # | |
InputPrep Text Source # | |
InputPrep Stream Source # | |
InputPrep CharList Source # | |
InputPrep Text16 Source # | |
InputPrep [Char] Source # | |
InputPrep (UArray Int Char) Source # | |
class PositionOps (rep :: TYPE r) where Source #
Defines operations for manipulating offsets for regular use. These are not tied to the original captured input but instead to the representation of its offset.
Since: 1.0.0.0
same :: Code rep -> Code rep -> Code Bool Source #
Compares two "input"s for equality. In reality this usually means an offset
present in the rep
.
Since: 1.0.0.0
shiftRight :: Code rep -> Code Int# -> Code rep Source #
Advances the input by several characters at a time (existence not included).
This can be used to check if characters exist at a future point in the input
in conjunction with more
.
Since: 1.0.0.0
Instances
PositionOps Text Source # | |
PositionOps Int# Source # | |
PositionOps UnpackedLazyByteString Source # | |
PositionOps (# Int#, [Char] #) Source # | |
PositionOps (# Int#, Stream #) Source # | |
class LogOps (rep :: TYPE r) where Source #
Defines operation used for debugging operations.
Since: 1.0.0.0
shiftLeft :: Code rep -> Code Int# -> Code rep Source #
If possible, shifts the input back several characters. This is used to provide the previous input characters for the debugging combinator.
Since: 1.0.0.0
offToInt :: Code rep -> Code Int Source #
Converts the represention of the input into an Int
.
Since: 1.0.0.0
data InputOps (rep :: TYPE r) Source #
This is a psuedo-typeclass, which depends directly on the values obtained from
InputDependant
. Because this instance must depend on local information, it is
synthesised and passed around using ImplicitParams
.
Since: 1.0.0.0
next :: forall r (rep :: TYPE r) a. (?ops :: InputOps rep) => Code rep -> (Code Char -> Code rep -> Code a) -> Code a Source #
type InputDependant (rep :: TYPE r) = (# rep -> (# Char, rep #), rep -> Bool, rep #) Source #
Given some associated representation type, defines the operations that work with a closed over instance of that type. These are:
next
: extract the next character from the input (existence not included)more
: query whether another character can be readinit
: the initial state of the input.
Since: 1.0.0.0