License | BSD-3-Clause |
---|---|
Maintainer | Jamie Willis |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Extensions |
|
This module contains the translation from user input type to the underlying parsley representation of it, as well as some miscellaneous functions for working with specific types of input (these do not appear in the rest of the machinery, but in Parsley.Internal.Backend.Machine.InputOps and potentially the generated code).
Since: 1.0.0.0
Synopsis
- type family DynRep input where ...
- type family StaRep input where ...
- type family RepKind input where ...
- data PartialStaOffset = StaO !(Code Int#) !Int
- dynOffset :: PartialStaOffset -> Code Int#
- intSame :: Code Int# -> Code Int# -> Code Bool
- intLess :: Code Int# -> Code Int# -> Code a -> Code a -> Code a
- intAdd :: PartialStaOffset -> Int -> PartialStaOffset
- intSubNonNeg :: PartialStaOffset -> Int -> PartialStaOffset
- min# :: Int# -> Int# -> Int#
- max# :: Int# -> Int# -> Int#
- type OffWith ts = (# Int#, ts #)
- offWithShiftRight :: Code (Int -> ts -> ts) -> PartialStaOffset -> Code ts -> Int -> (PartialStaOffset, Code ts)
- data PartialStaOffWith ts
- staOffWith :: PartialStaOffWith ts -> (PartialStaOffset -> Code ts -> Code a) -> Code a
- type UnpackedLazyByteString = (# Int#, Addr#, ForeignPtrContents, Int#, Int#, ByteString #)
- emptyUnpackedLazyByteString :: Code Int# -> Code UnpackedLazyByteString
- byteStringShiftRight :: Code UnpackedLazyByteString -> Int# -> Code UnpackedLazyByteString
- byteStringShiftLeft :: Code UnpackedLazyByteString -> Int# -> Code UnpackedLazyByteString
- dropStream :: Int -> Stream -> Stream
- data StaText = StaText {}
- data PartialStaText
- staText :: PartialStaText -> (StaText -> Code a) -> Code a
- offsetText :: PartialStaText -> Code Int
- textShiftRight :: Code Text -> Int# -> Code Text
- textShiftLeft :: Code Text -> Int# -> Code Text
- byteStringNext :: UnpackedLazyByteString -> (# Char, UnpackedLazyByteString #)
- textShiftRight# :: Text -> Int# -> Text
- textShiftLeft# :: Text -> Int# -> Text
- byteStringShiftRight# :: UnpackedLazyByteString -> Int# -> UnpackedLazyByteString
- byteStringShiftLeft# :: UnpackedLazyByteString -> Int# -> UnpackedLazyByteString
- data Stream = !Char :> Stream
- newtype CharList = CharList String
- newtype Text16 = Text16 Text
Representation Type-Families
type family DynRep input where ... Source #
This type family relates a user input type with the underlying parsley
representation, which is significantly more efficient to work with.
Most parts of the machine work with Rep
.
Since: 1.0.0.0
type family StaRep input where ... Source #
type family RepKind input where ... Source #
The representation type of an input Rep
, does not have to be a lifted type. To match a
representation of an input with the correct kind, this type family must be used.
Since: 1.0.0.0
RepKind String = 'TupleRep '[IntRep, LiftedRep] | |
RepKind (UArray Int Char) = IntRep | |
RepKind Text16 = LiftedRep | |
RepKind ByteString = IntRep | |
RepKind Text = LiftedRep | |
RepKind ByteString = 'TupleRep '[IntRep, AddrRep, LiftedRep, IntRep, IntRep, LiftedRep] | |
RepKind CharList = 'TupleRep '[IntRep, LiftedRep] | |
RepKind Stream = 'TupleRep '[IntRep, LiftedRep] |
Int#
Operations
data PartialStaOffset Source #
Instances
LogOps PartialStaOffset Source # | |
Defined in Parsley.Internal.Backend.Machine.InputOps shiftLeft :: PartialStaOffset -> Int -> (PartialStaOffset -> Code a) -> Code a Source # shiftRight :: PartialStaOffset -> Int -> (PartialStaOffset -> Code a) -> Code a Source # | |
PositionOps PartialStaOffset Source # | |
Defined in Parsley.Internal.Backend.Machine.InputOps same :: PartialStaOffset -> PartialStaOffset -> Code Bool Source # |
intSame :: Code Int# -> Code Int# -> Code Bool Source #
Verifies that two Int#
s are equal.
Since: 1.0.0.0
intLess :: Code Int# -> Code Int# -> Code a -> Code a -> Code a Source #
Is the first argument is less than the second?
Since: 2.3.0.0
intAdd :: PartialStaOffset -> Int -> PartialStaOffset Source #
intSubNonNeg :: PartialStaOffset -> Int -> PartialStaOffset Source #
Offwith
Operations
type OffWith ts = (# Int#, ts #) Source #
This allows types like String
and Stream
to be manipulated
more efficiently by packaging them along with an offset which can
be used for quicker comparisons.
Since: 1.0.0.0
:: Code (Int -> ts -> ts) | A |
-> PartialStaOffset | |
-> Code ts | The |
-> Int | How much to shift by. |
-> (PartialStaOffset, Code ts) |
Shifts an OffWith
to the right, taking care to also drop tokens from the
companion input.
Since: 1.0.0.0
data PartialStaOffWith ts Source #
Instances
LogOps (PartialStaOffWith Stream) Source # | |
Defined in Parsley.Internal.Backend.Machine.InputOps shiftLeft :: PartialStaOffWith Stream -> Int -> (PartialStaOffWith Stream -> Code a) -> Code a Source # shiftRight :: PartialStaOffWith Stream -> Int -> (PartialStaOffWith Stream -> Code a) -> Code a Source # | |
LogOps (PartialStaOffWith String) Source # | |
Defined in Parsley.Internal.Backend.Machine.InputOps shiftLeft :: PartialStaOffWith String -> Int -> (PartialStaOffWith String -> Code a) -> Code a Source # shiftRight :: PartialStaOffWith String -> Int -> (PartialStaOffWith String -> Code a) -> Code a Source # | |
PositionOps (PartialStaOffWith ts) Source # | |
Defined in Parsley.Internal.Backend.Machine.InputOps same :: PartialStaOffWith ts -> PartialStaOffWith ts -> Code Bool Source # |
staOffWith :: PartialStaOffWith ts -> (PartialStaOffset -> Code ts -> Code a) -> Code a Source #
LazyByteString
Operations
type UnpackedLazyByteString = (# Int#, Addr#, ForeignPtrContents, Int#, Int#, ByteString #) Source #
This type unpacks lazy ByteString
s for efficiency.
Since: 1.0.0.0
emptyUnpackedLazyByteString :: Code Int# -> Code UnpackedLazyByteString Source #
Initialises an UnpackedLazyByteString
with a specified offset.
This offset varies as each lazy chunk is consumed.
Since: 1.0.0.0
byteStringShiftRight :: Code UnpackedLazyByteString -> Int# -> Code UnpackedLazyByteString Source #
Drops tokens off of a lazy ByteString
.
Since: 2.3.0.0
byteStringShiftLeft :: Code UnpackedLazyByteString -> Int# -> Code UnpackedLazyByteString Source #
Rewinds input consumption on a lazy ByteString
if input is still available (within the same chunk).
Since: 2.3.0.0
Stream
Operations
Text
Operations
data PartialStaText Source #
Instances
LogOps PartialStaText Source # | |
Defined in Parsley.Internal.Backend.Machine.InputOps shiftLeft :: PartialStaText -> Int -> (PartialStaText -> Code a) -> Code a Source # shiftRight :: PartialStaText -> Int -> (PartialStaText -> Code a) -> Code a Source # | |
PositionOps PartialStaText Source # | |
Defined in Parsley.Internal.Backend.Machine.InputOps same :: PartialStaText -> PartialStaText -> Code Bool Source # |
offsetText :: PartialStaText -> Code Int Source #
Extracts the offset from Text
.
Since: 1.0.0.0
textShiftLeft :: Code Text -> Int# -> Code Text Source #
Rewinds input consumption on Text
where the input is still available (i.e. in the same chunk).
Since: 2.3.0.0
Crucial Exposed Functions
These functions must be exposed, since they can appear in the generated code.
byteStringNext :: UnpackedLazyByteString -> (# Char, UnpackedLazyByteString #) Source #
Re-exports
An input type that represents an infinite stream of input characters.
Since: 0.1.0.0
Instances
Deprecated: CharList is no longer necessary, use String directly instead
By wrapping a regular String
with this newtype, Parsley will not preprocess it into
an array of characters, instead using regular pattern matching for the implementation.
Since: 0.1.0.0
Instances
Deprecated: Text16 is not legal with the UTF-8 encoding of Text, use Text instead
By wrapping a regular Text
input with this newtype, Parsley will assume that all
of the characters fit into exactly one 16-bit chunk. This allows the consumption of
characters in the datatype to be consumed much faster, but does not support multi-word
characters.
Since: 0.1.0.0