]> Git — Sourcephile - haskell/symantic-parser.git/blob - src/Symantic/Parser/Machine.hs
doc: update ToDo
[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.Optimize
7 , module Symantic.Parser.Machine.Program
8 , module Symantic.Parser.Machine.View
9 ) where
10 import Data.Function ((.))
11 import Data.Ord (Ord)
12 import Text.Show (Show)
13 import qualified Language.Haskell.TH.Syntax as TH
14
15 import Symantic.Parser.Grammar
16 import Symantic.Parser.Machine.Generate
17 import Symantic.Parser.Machine.Input
18 import Symantic.Parser.Machine.Instructions
19 import Symantic.Parser.Machine.Optimize
20 import Symantic.Parser.Machine.Program
21 import Symantic.Parser.Machine.View
22
23 -- * Type 'Parser'
24 type Parser inp = ParserRepr Gen inp
25
26 -- | Like a 'Parser' but not bound to the 'Gen' interpreter.
27 type ParserRepr repr inp =
28 ObserveSharing TH.Name
29 (OptimizeGrammar (Program repr inp))
30
31 -- | Build a 'Machine' able to 'generateCode' for the given 'Parser'.
32 machine :: forall inp repr a.
33 Ord (InputToken inp) =>
34 Show (InputToken inp) =>
35 TH.Lift (InputToken inp) =>
36 Grammar (InputToken inp) (Program repr inp) =>
37 Machine (InputToken inp) repr =>
38 ParserRepr repr inp a ->
39 repr inp '[] ('Succ 'Zero) a
40 machine = optimizeMachine . grammar @(InputToken inp)