diff options
| author | Thomas H <Thomas-H@users.noreply.github.com> | 2018-08-06 16:31:55 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-06 16:31:55 +0200 |
| commit | e89e5f13bf50767665507aa7ffe0ccd813cb70f4 (patch) | |
| tree | 6c3143881c1b2b3aa67f25070c99f76e4fd04032 /src/runtime | |
| parent | d9f0dfd400444d6ab9945bb8d2bb085b43baa358 (diff) | |
| parent | 6b2c2256d17eeca69229a54371f169795c58a803 (diff) | |
Merge pull request #3 from MUSTE-Project/master
A version of `readPGF` where the user can handle reading files
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/haskell/PGF.hs | 13 | ||||
| -rw-r--r-- | src/runtime/haskell/pgf.cabal | 2 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/runtime/haskell/PGF.hs b/src/runtime/haskell/PGF.hs index 134a13c3b..3cd417c73 100644 --- a/src/runtime/haskell/PGF.hs +++ b/src/runtime/haskell/PGF.hs @@ -17,6 +17,7 @@ module PGF( -- * PGF PGF, readPGF, + parsePGF, -- * Identifiers CId, mkCId, wildCId, @@ -165,7 +166,7 @@ import PGF.Macros import PGF.Expr (Tree) import PGF.Morphology import PGF.Data -import PGF.Binary() +import PGF.Binary () import qualified PGF.Forest as Forest import qualified PGF.Parse as Parse import PGF.Utilities(replace) @@ -175,6 +176,7 @@ import qualified Data.Map as Map --import qualified Data.IntMap as IntMap --import Data.Maybe import Data.Binary +import Data.ByteString.Lazy (ByteString) import Data.List(mapAccumL) --import System.Random (newStdGen) --import Control.Monad @@ -190,6 +192,11 @@ import Text.PrettyPrint -- > $ gf -make <grammar file name> readPGF :: FilePath -> IO PGF +-- | Like @readPGF@ but you have the manage file-handling. +-- +-- @since 3.9.1 +parsePGF :: ByteString -> PGF + -- | Tries to parse the given string in the specified language -- and to produce abstract syntax expression. parse :: PGF -> Language -> Type -> String -> [Tree] @@ -254,7 +261,9 @@ functionType :: PGF -> CId -> Maybe Type -- Implementation --------------------------------------------------- -readPGF f = decodeFile f +readPGF = decodeFile + +parsePGF = decode parse pgf lang typ s = case parse_ pgf lang typ (Just 4) s of diff --git a/src/runtime/haskell/pgf.cabal b/src/runtime/haskell/pgf.cabal index 8e1fa72b2..8a84dc278 100644 --- a/src/runtime/haskell/pgf.cabal +++ b/src/runtime/haskell/pgf.cabal @@ -1,5 +1,5 @@ name: pgf -version: 3.9-git +version: 3.9.1-git cabal-version: >= 1.20 build-type: Simple |
