License | BSD-3-Clause |
---|---|
Maintainer | Jamie Willis |
Stability | unstable |
Safe Haskell | None |
Language | Haskell2010 |
This module exposes all of the required functionality found in the internals of the library out to the user API.
Since: 0.1.0.0
Synopsis
- module Parsley.Internal.Core
- data Reg (r :: Type) a
- conditional :: ParserOps rep => [(rep (a -> Bool), Parser b)] -> Parser a -> Parser b -> Parser b
- pure :: ParserOps rep => rep a -> Parser a
- satisfy :: ParserOps rep => rep (Char -> Bool) -> Parser Char
- (<*>) :: Parser (a -> b) -> Parser a -> Parser b
- (<*) :: Parser a -> Parser b -> Parser a
- (*>) :: Parser a -> Parser b -> Parser b
- empty :: Parser a
- (<|>) :: Parser a -> Parser a -> Parser a
- lookAhead :: Parser a -> Parser a
- notFollowedBy :: Parser a -> Parser ()
- try :: Parser a -> Parser a
- branch :: Parser (Either a b) -> Parser (a -> c) -> Parser (b -> c) -> Parser c
- chainPre :: Parser (a -> a) -> Parser a -> Parser a
- chainPost :: Parser a -> Parser (a -> a) -> Parser a
- loop :: Parser () -> Parser a -> Parser a
- newRegister :: Parser a -> (forall r. Reg r a -> Parser b) -> Parser b
- get :: Reg r a -> Parser a
- put :: Reg r a -> Parser a -> Parser ()
- debug :: String -> Parser a -> Parser a
- class Quapplicative q where
- data WQ a
- type Code a = Q (TExp a)
- class Trace where
- compile :: forall compiled a. Trace => Parser a -> (forall x. Maybe (MVar x) -> Fix Combinator x -> Set SomeΣVar -> IMVar -> compiled x) -> (compiled a, DMap MVar compiled)
- class (InputPrep input, Ops input) => Input input
- eval :: forall input a. (Input input, Trace) => Code input -> (LetBinding input a a, DMap MVar (LetBinding input a)) -> Code (Maybe a)
- codeGen :: Trace => Maybe (MVar x) -> Fix Combinator x -> Set SomeΣVar -> IMVar -> LetBinding o a x
- parse :: (Trace, Input input) => Parser a -> Code (input -> Maybe a)
Documentation
module Parsley.Internal.Core
data Reg (r :: Type) a Source #
This is an opaque representation of a parsing register. It cannot be manipulated as a user, and the
type parameter r
is used to ensure that it cannot leak out of the scope it has been created in.
It is the abstracted representation of a runtime storage location.
Since: 0.1.0.0
conditional :: ParserOps rep => [(rep (a -> Bool), Parser b)] -> Parser a -> Parser b -> Parser b Source #
notFollowedBy :: Parser a -> Parser () Source #
class Quapplicative q where Source #
This class is used to manipulate the representations of both user-land values and defunctionalised representations. It can be used to construct these values as well as extract their underlying value and code representation on demand.
It is named after the Applicative
class, with the Q
standing for "code". The (
operator
is analogous to >*<
)(<*>)
and makeQ
analogous to pure
.
Since: 0.1.0.0
makeQ :: a -> Code a -> q a Source #
Combines a value with its representation to build one of the representation types.
Since: 0.1.0.0
Extracts the regular value out of the representation.
Since: 0.1.0.0
_code :: q a -> Code a Source #
Extracts the representation of the value as code.
Since: 0.1.0.0
(>*<) :: q (a -> b) -> q a -> q b infixl 9 Source #
Pronounced "quapp", this can be used to combine the code of a function with the code of a value.
const5 = makeQ const [||const||] >*< makeQ 5 [||5||]
is the same as saying
const5 = makeQ (const 5) [||const 5||]
It is more idiomatically found as the output to the IdiomsPlugin
.
Since: 0.1.0.0
Instances
Quapplicative WQ Source # | This instance is used to manipulate values of Since: 0.1.0.0 |
Quapplicative Defunc Source # | This instance is used to manipulate values of Since: 0.1.0.0 |
Pronounced "with code", this datatype is the representation for user-land values. It pairs
a value up with its representation as Haskell Code
. It should be manipulated using
Quapplicative
.
Since: 0.1.0.0
type Code a = Q (TExp a) Source #
A type alias for typed template haskell code, which represents the Haskell AST for a given value.
Since: 0.1.0.0
Used to produce debug output within parsley.
Since: 0.1.0.0
:: forall compiled a. Trace | |
=> Parser a | The parser to compile. |
-> (forall x. Maybe (MVar x) -> Fix Combinator x -> Set SomeΣVar -> IMVar -> compiled x) | How to generate a compiled value with the distilled information. |
-> (compiled a, DMap MVar compiled) | The compiled top-level and all of the bindings. |
Given a user's parser, this will analyse it, extract bindings and then compile them with a given function provided with the information that has been distilled about each binding. Returns all the prepared bindings along with the top-level definition.
Since: 1.0.0.0
class (InputPrep input, Ops input) => Input input Source #
This class is exposed to parsley itself and is used to denote which types may be used as input for a parser.
Since: 0.1.0.0
Instances
Input ByteString Source # | |
Defined in Parsley.Internal.Backend.Machine | |
Input ByteString Source # | |
Defined in Parsley.Internal.Backend.Machine | |
Input Text Source # | |
Defined in Parsley.Internal.Backend.Machine | |
Input Stream Source # | |
Defined in Parsley.Internal.Backend.Machine | |
Input CharList Source # | |
Defined in Parsley.Internal.Backend.Machine | |
Input Text16 Source # | |
Defined in Parsley.Internal.Backend.Machine | |
Input [Char] Source # | |
Defined in Parsley.Internal.Backend.Machine | |
Input (UArray Int Char) Source # | |
Defined in Parsley.Internal.Backend.Machine |
eval :: forall input a. (Input input, Trace) => Code input -> (LetBinding input a a, DMap MVar (LetBinding input a)) -> Code (Maybe a) Source #
This function is exposed to parsley itself and is used to generate the Haskell code for a parser.
Since: 0.1.0.0
:: Trace | |
=> Maybe (MVar x) | The name of the parser, if it exists. |
-> Fix Combinator x | The definition of the parser. |
-> Set SomeΣVar | The free registers it requires to run. |
-> IMVar | The binding identifier to start name generation from. |
-> LetBinding o a x |
Translates a parser represented with combinators into its machine representation.
Since: 1.0.0.0