]> Git — Sourcephile - haskell/symantic-parser.git/blob - src/Symantic/Parser.hs
tests: add more tests
[haskell/symantic-parser.git] / src / Symantic / Parser.hs
1 module Symantic.Parser
2 ( module Symantic.Parser.Grammar
3 , module Symantic.Parser.Machine
4 , module Symantic.Parser
5 ) where
6
7 import Control.Monad.ST (ST, RealWorld)
8 import Data.Function (($))
9 import Language.Haskell.TH (CodeQ)
10 import qualified Language.Haskell.TH.Syntax as TH
11
12 import Symantic.Parser.Grammar
13 import Symantic.Parser.Machine
14
15 -- * Type 'Parser'
16 type Parser inp a = Machine Gen inp a
17
18 -- ** Type 'Parsed'
19 type Parsed inp a = ST RealWorld (Result inp a)
20
21 runParser :: forall inp a.
22 Inputable inp =>
23 Machinable (InputToken inp) Gen =>
24 Parser inp a ->
25 CodeQ (inp -> Parsed inp a)
26 runParser p = TH.Code $ do
27 mach <- TH.runIO $ machine p
28 TH.examineCode $ generateCode mach