1 {-# LANGUAGE TemplateHaskell #-}
3 ( module Symantic.Parser.Grammar
4 , module Symantic.Parser.Machine
5 , module Symantic.Parser
8 import Data.Either (Either(..))
9 import Data.Function (($))
11 import Language.Haskell.TH (CodeQ)
12 import Text.Show (Show)
13 import Type.Reflection (Typeable)
14 import qualified Language.Haskell.TH.Syntax as TH
16 import Symantic.Parser.Grammar
17 import Symantic.Parser.Machine
19 runParser :: forall inp a.
20 Ord (InputToken inp) =>
21 Show (InputToken inp) =>
22 TH.Lift (InputToken inp) =>
23 Typeable (InputToken inp) =>
24 -- InputToken inp ~ Char =>
26 InstrReadable (InputToken inp) Gen =>
28 CodeQ (inp -> Either (ParsingError inp) a)
29 runParser p = TH.Code $ do
30 mach <- TH.runIO $ machine p
31 TH.examineCode $ generateCode mach