mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-07 18:22:50 -06:00
added function abstractName from the API
This commit is contained in:
@@ -14,10 +14,17 @@
|
||||
-------------------------------------------------
|
||||
|
||||
module PGF2 (-- * PGF
|
||||
PGF,readPGF
|
||||
PGF,readPGF,
|
||||
|
||||
-- * Abstract syntax
|
||||
AbsName,abstractName,
|
||||
|
||||
-- * Concrete syntax
|
||||
ConcName
|
||||
) where
|
||||
|
||||
import Control.Exception(Exception,throwIO,mask_)
|
||||
import Control.Exception(Exception,throwIO,mask_,bracket)
|
||||
import System.IO.Unsafe(unsafePerformIO)
|
||||
import PGF2.FFI
|
||||
|
||||
import Foreign
|
||||
@@ -27,6 +34,9 @@ import qualified Data.Map as Map
|
||||
|
||||
#include <pgf.h>
|
||||
|
||||
type AbsName = String -- ^ Name of abstract syntax
|
||||
type ConcName = String -- ^ Name of concrete syntax
|
||||
|
||||
readPGF :: FilePath -> IO PGF
|
||||
readPGF fpath =
|
||||
withCString fpath $ \c_fpath ->
|
||||
@@ -45,6 +55,15 @@ readPGF fpath =
|
||||
free c_msg
|
||||
throwIO (PGFError msg)
|
||||
|
||||
-- | The abstract language name is the name of the top-level
|
||||
-- abstract module
|
||||
abstractName :: PGF -> AbsName
|
||||
abstractName p =
|
||||
unsafePerformIO $
|
||||
withForeignPtr (a_pgf p) $ \c_pgf ->
|
||||
bracket (pgf_abstract_name c_pgf) free $ \c_text ->
|
||||
peekText c_text
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
-- Exceptions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user