module Symantic.Parser.Machine ( module Symantic.Parser.Machine , module Symantic.Parser.Machine.Generate , module Symantic.Parser.Machine.Input , module Symantic.Parser.Machine.Instructions , module Symantic.Parser.Machine.View ) where import Data.Function ((.)) import Data.Ord (Ord) import Symantic.Parser.Machine.Input import Symantic.Parser.Grammar import Text.Show (Show) import qualified Language.Haskell.TH.Syntax as TH import Symantic.Parser.Machine.Instructions import Symantic.Parser.Machine.Build import Symantic.Parser.Machine.Generate import Symantic.Parser.Machine.View -- * Type 'Parser' type Parser inp = ParserRepr Gen inp -- | Like a 'Parser' but not bound to the 'Gen' interpreter. type ParserRepr repr inp = ObserveSharing TH.Name (OptimizeGrammar TH.Name (Machine repr inp)) -- | Build a 'Machine' able to 'generate' the given 'Parser'. machine :: forall inp repr a. Ord (InputToken inp) => Show (InputToken inp) => TH.Lift (InputToken inp) => Executable (InputToken inp) repr => Grammar (Machine repr inp) => ParserRepr repr inp a -> repr inp '[] ('Succ 'Zero) a machine = runMachine . optimizeGrammar . observeSharing