module HyLo.InputFile ( InputFile, parse, myparse, write, parseOldFormat, OldInputFile,
)
where
import Control.Monad.State
import HyLo.Formula ( Formula,
)
import HyLo.Signature.String ( NomSymbol(..), PropSymbol, RelSymbol )
import qualified HyLo.Signature.Simple as Simple
import qualified HyLo.InputFile.Lexer as L
import qualified HyLo.InputFile.Parser as P
import qualified HyLo.InputFile.OldLexer as Old.L
import qualified HyLo.InputFile.OldParser as Old.P
type InputFile = [Formula NomSymbol PropSymbol RelSymbol]
runParser :: State P.ParseState a -> a
runParser r = evalState r P.initParseState
parse :: String -> InputFile
parse = P.theory . runParser . P.parse . L.alexScanTokens
myparse :: String -> P.ParseOutput
myparse = runParser . P.parse . L.alexScanTokens
write :: (Show n, Show p, Show r) => [Formula n p r] -> String
write input = unlines $ "{":addSemicolon (map show input) ++ ["}"]
where addSemicolon (x:xs@(_:_)) = (x ++ ";") : addSemicolon xs
addSemicolon xs = xs
type OldInputFile = [Formula Simple.NomSymbol Simple.PropSymbol Simple.RelSymbol]
parseOldFormat :: String -> OldInputFile
parseOldFormat = Old.P.parse . Old.L.alexScanTokens