]> Git — Sourcephile - haskell/symantic-parser.git/blob - src/Symantic/Parser.hs
grammar: open the Comb data-type
[haskell/symantic-parser.git] / src / Symantic / Parser.hs
1 {-# LANGUAGE TemplateHaskell #-}
2 module Symantic.Parser
3 ( module Symantic.Parser.Grammar
4 , module Symantic.Parser.Machine
5 , module Symantic.Parser
6 ) where
7
8 import Data.Either (Either(..))
9 import Data.Ord (Ord)
10 import Language.Haskell.TH (CodeQ)
11 import Text.Show (Show)
12 import Type.Reflection (Typeable)
13 import qualified Language.Haskell.TH.Syntax as TH
14
15 import Symantic.Parser.Grammar
16 import Symantic.Parser.Machine
17
18 runParser :: forall inp a.
19 Ord (InputToken inp) =>
20 Show (InputToken inp) =>
21 TH.Lift (InputToken inp) =>
22 Typeable (InputToken inp) =>
23 -- InputToken inp ~ Char =>
24 Input inp =>
25 Readable (InputToken inp) Gen =>
26 Parser inp a ->
27 CodeQ (inp -> Either (ParsingError inp) a)
28 runParser p = [|| \input -> $$(generate [||input||] (machine p)) ||]