1 {-# LANGUAGE TemplateHaskell #-}
2 module Symantic.Parser.Automaton
3 ( module Symantic.Parser.Automaton
4 , module Symantic.Parser.Automaton.Instructions
5 , module Symantic.Parser.Automaton.Dump
6 , module Symantic.Parser.Automaton.Eval
7 , module Symantic.Parser.Automaton.Input
9 import Symantic.Parser.Automaton.Instructions
10 import Symantic.Parser.Automaton.Dump
11 import Symantic.Parser.Automaton.Eval
12 import Data.Either (Either(..))
14 import Symantic.Parser.Grammar
15 import Symantic.Parser.Automaton.Input
16 import Data.Function ((.))
17 import Language.Haskell.TH (CodeQ)
18 import qualified Language.Haskell.TH.Syntax as TH
21 ObserveSharing TH.Name
25 automaton :: forall inp repr a.
27 Grammar (Automaton inp) =>
29 repr inp '[] ('Succ 'Zero) a
30 automaton = runAutomaton . optimizeComb . observeSharing
32 runParser :: forall inp a.
34 Parser (Cursor inp) a ->
35 CodeQ (inp -> Either ParsingError a)
36 runParser p = [||\input -> $$(eval [||input||] (automaton p))||]