mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-23 09:52:55 -06:00
Merge pull request #3 from MUSTE-Project/master
A version of `readPGF` where the user can handle reading files
This commit is contained in:
@@ -17,6 +17,7 @@ module PGF(
|
|||||||
-- * PGF
|
-- * PGF
|
||||||
PGF,
|
PGF,
|
||||||
readPGF,
|
readPGF,
|
||||||
|
parsePGF,
|
||||||
|
|
||||||
-- * Identifiers
|
-- * Identifiers
|
||||||
CId, mkCId, wildCId,
|
CId, mkCId, wildCId,
|
||||||
@@ -175,6 +176,7 @@ import qualified Data.Map as Map
|
|||||||
--import qualified Data.IntMap as IntMap
|
--import qualified Data.IntMap as IntMap
|
||||||
--import Data.Maybe
|
--import Data.Maybe
|
||||||
import Data.Binary
|
import Data.Binary
|
||||||
|
import Data.ByteString.Lazy (ByteString)
|
||||||
import Data.List(mapAccumL)
|
import Data.List(mapAccumL)
|
||||||
--import System.Random (newStdGen)
|
--import System.Random (newStdGen)
|
||||||
--import Control.Monad
|
--import Control.Monad
|
||||||
@@ -190,6 +192,11 @@ import Text.PrettyPrint
|
|||||||
-- > $ gf -make <grammar file name>
|
-- > $ gf -make <grammar file name>
|
||||||
readPGF :: FilePath -> IO PGF
|
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
|
-- | Tries to parse the given string in the specified language
|
||||||
-- and to produce abstract syntax expression.
|
-- and to produce abstract syntax expression.
|
||||||
parse :: PGF -> Language -> Type -> String -> [Tree]
|
parse :: PGF -> Language -> Type -> String -> [Tree]
|
||||||
@@ -254,7 +261,9 @@ functionType :: PGF -> CId -> Maybe Type
|
|||||||
-- Implementation
|
-- Implementation
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
|
|
||||||
readPGF f = decodeFile f
|
readPGF = decodeFile
|
||||||
|
|
||||||
|
parsePGF = decode
|
||||||
|
|
||||||
parse pgf lang typ s =
|
parse pgf lang typ s =
|
||||||
case parse_ pgf lang typ (Just 4) s of
|
case parse_ pgf lang typ (Just 4) s of
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: pgf
|
name: pgf
|
||||||
version: 3.9-git
|
version: 3.9.1-git
|
||||||
|
|
||||||
cabal-version: >= 1.20
|
cabal-version: >= 1.20
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
|
|||||||
Reference in New Issue
Block a user