| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Symantic.Parser.Machine.Program
Contents
Description
Synopsis
- data Program repr inp a = Program {}
- optimizeMachine :: forall inp es repr a. Machine (InputToken inp) repr => Program repr inp a -> repr inp '[] ('Succ es) a
- failIfConsumed :: Cursorable (Cursor inp) => Branchable repr => Failable repr => Inputable repr => Stackable repr => SomeInstr repr inp vs ('Succ es) ret -> SomeInstr repr inp (Cursor inp ': vs) ('Succ es) ret
- joinNext :: Joinable repr => Program repr inp v -> Program repr inp v
Type Program
data Program repr inp a Source #
A Program is a tree of Instructions,
where each Instruction is built by a continuation
to be able to introspect, duplicate and/or change
the next Instruction.
Constructors
| Program | |
Instances
| Routinable repr => Letable Name (Program repr inp) Source # | |
| (tok ~ InputToken inp, Readable tok repr, Typeable tok) => Satisfiable tok (Program repr inp) Source # | |
| (Ord (InputToken inp), Cursorable (Cursor inp), Branchable repr, Failable repr, Inputable repr, Joinable repr, Readable (InputToken inp) repr, Typeable (InputToken inp), Stackable repr) => Lookable (Program repr inp) Source # | |
| (Cursorable (Cursor inp), Branchable repr, Failable repr, Inputable repr, Joinable repr, Stackable repr) => Foldable (Program repr inp) Source # | |
| (Branchable repr, Joinable repr) => Matchable (Program repr inp) Source # | |
Defined in Symantic.Parser.Machine.Program Methods conditional :: Eq a => Program repr inp a -> [TermGrammar (a -> Bool)] -> [Program repr inp b] -> Program repr inp b -> Program repr inp b Source # match :: Eq a => Program repr inp a -> [TermGrammar a] -> (TermGrammar a -> Program repr inp b) -> Program repr inp b -> Program repr inp b Source # | |
| (Branchable repr, Joinable repr, Stackable repr) => Selectable (Program repr inp) Source # | |
| (Cursorable (Cursor inp), Branchable repr, Failable repr, Inputable repr, Joinable repr, Stackable repr) => Alternable (Program repr inp) Source # | |
Defined in Symantic.Parser.Machine.Program Methods (<|>) :: Program repr inp a -> Program repr inp a -> Program repr inp a Source # empty :: Program repr inp a Source # try :: Program repr inp a -> Program repr inp a Source # (<+>) :: (Applicable (Program repr inp), Alternable (Program repr inp)) => Program repr inp a -> Program repr inp b -> Program repr inp (Either a b) Source # | |
| Stackable repr => Applicable (Program repr inp) Source # | |
Defined in Symantic.Parser.Machine.Program Methods (<$>) :: TermGrammar (a -> b) -> Program repr inp a -> Program repr inp b Source # (<&>) :: Program repr inp a -> TermGrammar (a -> b) -> Program repr inp b Source # (<$) :: TermGrammar a -> Program repr inp b -> Program repr inp a Source # ($>) :: Program repr inp a -> TermGrammar b -> Program repr inp b Source # pure :: TermGrammar a -> Program repr inp a Source # (<*>) :: Program repr inp (a -> b) -> Program repr inp a -> Program repr inp b Source # liftA2 :: TermGrammar (a -> b -> c) -> Program repr inp a -> Program repr inp b -> Program repr inp c Source # (<*) :: Program repr inp a -> Program repr inp b -> Program repr inp a Source # (*>) :: Program repr inp a -> Program repr inp b -> Program repr inp b Source # (<**>) :: Program repr inp a -> Program repr inp (a -> b) -> Program repr inp b Source # | |
optimizeMachine :: forall inp es repr a. Machine (InputToken inp) repr => Program repr inp a -> repr inp '[] ('Succ es) a Source #
failIfConsumed :: Cursorable (Cursor inp) => Branchable repr => Failable repr => Inputable repr => Stackable repr => SomeInstr repr inp vs ('Succ es) ret -> SomeInstr repr inp (Cursor inp ': vs) ('Succ es) ret Source #
If no input has been consumed by the failing alternative
then continue with the given continuation.
Otherwise, propagate the Failure.
joinNext :: Joinable repr => Program repr inp v -> Program repr inp v Source #
( factorize the next joinNext m)Instruction
to be able to reuse it multiple times without duplication.
It does so by introducing a defJoin
and passing the corresponding refJoin
as next Instruction to (m),
unless factorizing is useless because the next Instruction
is already a refJoin or a ret.
It should be used each time the next Instruction
is used multiple times.