mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-19 17:59:32 -06:00
added startCat
This commit is contained in:
@@ -3,7 +3,7 @@ module PGF ( PGF2.PGF, readPGF
|
||||
|
||||
, CId, mkCId, wildCId, showCId, readCId
|
||||
|
||||
, categories
|
||||
, PGF2.categories, PGF2.categoryContext, PGF2.startCat
|
||||
, functions, functionsByCat
|
||||
|
||||
, PGF2.Expr(..), PGF2.Literal(..), Tree
|
||||
|
||||
@@ -33,7 +33,7 @@ module PGF2 (-- * PGF
|
||||
mkFloat, unFloat,
|
||||
mkMeta, unMeta,
|
||||
-- ** Types
|
||||
Type(..), Hypo, BindType(..),
|
||||
Type(..), Hypo, BindType(..), startCat,
|
||||
readType,
|
||||
mkType, unType,
|
||||
mkHypo, mkDepHypo, mkImplHypo,
|
||||
@@ -139,6 +139,20 @@ abstractName p =
|
||||
bracket (pgf_abstract_name p_pgf) free $ \c_text ->
|
||||
peekText c_text
|
||||
|
||||
-- | The start category is defined in the grammar with
|
||||
-- the \'startcat\' flag. This is usually the sentence category
|
||||
-- but it is not necessary. Despite that there is a start category
|
||||
-- defined you can parse with any category. The start category
|
||||
-- definition is just for convenience.
|
||||
startCat :: PGF -> Type
|
||||
startCat p =
|
||||
unsafePerformIO $
|
||||
withForeignPtr (a_pgf p) $ \c_pgf -> do
|
||||
c_typ <- pgf_start_cat c_pgf
|
||||
typ <- deRefStablePtr c_typ
|
||||
freeStablePtr c_typ
|
||||
return typ
|
||||
|
||||
-- | The type of a function
|
||||
functionType :: PGF -> Fun -> Maybe Type
|
||||
functionType p fn =
|
||||
|
||||
@@ -63,6 +63,9 @@ foreign import ccall "wrapper"
|
||||
foreign import ccall "pgf_iter_categories"
|
||||
pgf_iter_categories :: Ptr PgfPGF -> Ptr PgfItor -> IO ()
|
||||
|
||||
foreign import ccall "pgf_start_cat"
|
||||
pgf_start_cat :: Ptr PgfPGF -> IO (StablePtr Type)
|
||||
|
||||
foreign import ccall "pgf/pgf.h pgf_category_context"
|
||||
pgf_category_context :: Ptr PgfPGF -> Ptr PgfText -> Ptr CSize -> IO (Ptr PgfTypeHypo)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user