Syntax.hs 1.28 KB
Newer Older
Bjoern Peemoeller's avatar
Bjoern Peemoeller committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{- |A simple interface for reading and manipulating Curry source code.

    (c) 2009, Holger Siegel
        2011, Björn Peemöller
-}
module Curry.Syntax
  ( module Curry.Syntax.Type
  , module Curry.Syntax.Utils
  , lexFile
  , parseHeader
  , parseModule
  , ppModule, ppIDecl
  , showModule
  ) where

import Curry.Base.Position (Position, first)
import Curry.Base.MessageMonad (MsgMonad)
import Curry.Files.Unlit (unlit)
import qualified Curry.Syntax.Lexer as Lexer (Token, lexFile)
import qualified Curry.Syntax.Parser as Parser (parseHeader, parseSource)
import Curry.Syntax.Pretty (ppModule, ppIDecl)
import Curry.Syntax.ShowModule (showModule)
import Curry.Syntax.Type
import Curry.Syntax.Utils

{- |Return the result of a lexical analysis of the source program 'src'.
    The result is a list of tuples consisting of a 'Position' and a 'Token'
-}
lexFile :: FilePath -> String -> MsgMonad [(Position, Lexer.Token)]
lexFile fn src = unlit fn src >>= \s -> Lexer.lexFile (first fn) s False []

-- | Parse a curry header
parseHeader :: FilePath -> String -> MsgMonad Module
parseHeader fn src = unlit fn src >>= Parser.parseHeader fn

-- | Parse a curry module
parseModule :: Bool -> FilePath -> String -> MsgMonad Module
parseModule likeFlat fn src = unlit fn src >>= Parser.parseSource likeFlat fn