{-# LANGUAGE FlexibleContexts #-}

module Jikka.Python.Parse
  ( run,
  )
where

import Data.Text (Text, unpack)
import Jikka.Common.Error
import Jikka.Python.Language.Expr (Program)
import qualified Jikka.Python.Parse.Alex as L
import qualified Jikka.Python.Parse.Happy as P

run :: MonadError Error m => FilePath -> Text -> m Program
run :: FilePath -> Text -> m Program
run FilePath
_ Text
input = do
  [Token']
tokens <- FilePath -> m [Token']
forall (m :: * -> *). MonadError Error m => FilePath -> m [Token']
L.run (FilePath -> m [Token']) -> FilePath -> m [Token']
forall a b. (a -> b) -> a -> b
$ Text -> FilePath
unpack Text
input
  [Token'] -> m Program
forall (m :: * -> *). MonadError Error m => [Token'] -> m Program
P.run [Token']
tokens