]> Git — Sourcephile - haskell/symantic-parser.git/blob - src/Symantic/Parser/Machine.hs
grammar: open the Comb data-type
[haskell/symantic-parser.git] / src / Symantic / Parser / Machine.hs
1 module Symantic.Parser.Machine
2 ( module Symantic.Parser.Machine
3 , module Symantic.Parser.Machine.Generate
4 , module Symantic.Parser.Machine.Input
5 , module Symantic.Parser.Machine.Instructions
6 , module Symantic.Parser.Machine.View
7 ) where
8 import Data.Function ((.))
9 import Data.Ord (Ord)
10 import Symantic.Parser.Machine.Input
11 import Symantic.Parser.Grammar
12 import Text.Show (Show)
13 import qualified Language.Haskell.TH.Syntax as TH
14
15 import Symantic.Parser.Machine.Instructions
16 import Symantic.Parser.Machine.Build
17 import Symantic.Parser.Machine.Generate
18 import Symantic.Parser.Machine.View
19
20 -- * Type 'Parser'
21 type Parser inp = ParserRepr Gen inp
22
23 -- | Like a 'Parser' but not bound to the 'Gen' interpreter.
24 type ParserRepr repr inp =
25 ObserveSharing TH.Name
26 (OptimizeGrammar TH.Name
27 (Machine repr inp))
28
29 -- | Build a 'Machine' able to 'generate' the given 'Parser'.
30 machine :: forall inp repr a.
31 Ord (InputToken inp) =>
32 Show (InputToken inp) =>
33 TH.Lift (InputToken inp) =>
34 Grammar (InputToken inp) (Machine repr inp) =>
35 Executable (InputToken inp) repr =>
36 ParserRepr repr inp a ->
37 repr inp '[] ('Succ 'Zero) a
38 machine = runMachine . optimizeGrammar . observeSharing