]> Git — Sourcephile - haskell/symantic-parser.git/blob - src/Symantic/Parser.hs
machine: optimize ifThenElse on constant
[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 Data.Either (Either)
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 runParser :: forall inp a.
19 Inputable inp =>
20 Machinable (InputToken inp) Gen =>
21 Parser inp a ->
22 CodeQ (inp -> Either (ParsingError inp) a)
23 runParser p = TH.Code $ do
24 mach <- TH.runIO $ machine p
25 TH.examineCode $ generateCode mach