{-# LANGUAGE Safe #-}
module Parser.SourceFile (
parseInternalSource,
parsePublicSource,
parseTestSource,
) where
import Text.Parsec
import Text.Parsec.String
import Base.CompileError
import Parser.Common
import Parser.DefinedCategory
import Parser.IntegrationTest
import Parser.TypeCategory
import Types.DefinedCategory
import Types.IntegrationTest
import Types.Positional
import Types.TypeCategory
parseInternalSource :: CompileErrorM m =>
(String,String) -> m ([AnyCategory SourcePos],[DefinedCategory SourcePos])
parseInternalSource (f,s) = unwrap parsed where
parsed = parse (between optionalSpace endOfDoc parseAnySource) f s
unwrap (Left e) = compileError (show e)
unwrap (Right t) = return t
parsePublicSource :: CompileErrorM m => (String,String) -> m [AnyCategory SourcePos]
parsePublicSource (f,s) = unwrap parsed where
parsed = parse (between optionalSpace endOfDoc (sepBy sourceParser optionalSpace)) f s
unwrap (Left e) = compileError (show e)
unwrap (Right t) = return t
parseTestSource :: CompileErrorM m => (String,String) -> m [IntegrationTest SourcePos]
parseTestSource (f,s) = unwrap parsed where
parsed = parse (between optionalSpace endOfDoc (sepBy sourceParser optionalSpace)) f s
unwrap (Left e) = compileError (show e)
unwrap (Right t) = return t