mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-26 19:28:54 -06:00
added function printName in the Haskell binding
This commit is contained in:
@@ -55,9 +55,11 @@ module PGF2 (-- * PGF
|
|||||||
|
|
||||||
-- * Concrete syntax
|
-- * Concrete syntax
|
||||||
ConcName,Concr,languages,concreteName,languageCode,
|
ConcName,Concr,languages,concreteName,languageCode,
|
||||||
|
|
||||||
-- ** Linearization
|
-- ** Linearization
|
||||||
linearize,linearizeAll,tabularLinearize,tabularLinearizeAll,bracketedLinearize,
|
linearize,linearizeAll,tabularLinearize,tabularLinearizeAll,bracketedLinearize,
|
||||||
FId, LIndex, BracketedString(..), showBracketedString, flattenBracketedString,
|
FId, LIndex, BracketedString(..), showBracketedString, flattenBracketedString,
|
||||||
|
printName,
|
||||||
|
|
||||||
alignWords,
|
alignWords,
|
||||||
-- ** Parsing
|
-- ** Parsing
|
||||||
@@ -911,6 +913,7 @@ alignWords lang e = unsafePerformIO $
|
|||||||
withGuPool $ \pl ->
|
withGuPool $ \pl ->
|
||||||
do exn <- gu_new_exn pl
|
do exn <- gu_new_exn pl
|
||||||
seq <- pgf_align_words (concr lang) (expr e) exn pl
|
seq <- pgf_align_words (concr lang) (expr e) exn pl
|
||||||
|
touchConcr lang
|
||||||
touchExpr e
|
touchExpr e
|
||||||
failed <- gu_exn_is_raised exn
|
failed <- gu_exn_is_raised exn
|
||||||
if failed
|
if failed
|
||||||
@@ -935,6 +938,18 @@ alignWords lang e = unsafePerformIO $
|
|||||||
(fids :: [CInt]) <- peekArray (fromIntegral (n_fids :: CInt)) (ptr `plusPtr` (#offset PgfAlignmentPhrase, fids))
|
(fids :: [CInt]) <- peekArray (fromIntegral (n_fids :: CInt)) (ptr `plusPtr` (#offset PgfAlignmentPhrase, fids))
|
||||||
return (phrase, map fromIntegral fids)
|
return (phrase, map fromIntegral fids)
|
||||||
|
|
||||||
|
printName :: Concr -> Fun -> Maybe String
|
||||||
|
printName lang fun =
|
||||||
|
unsafePerformIO $
|
||||||
|
withGuPool $ \tmpPl -> do
|
||||||
|
c_fun <- newUtf8CString fun tmpPl
|
||||||
|
c_name <- pgf_print_name (concr lang) c_fun
|
||||||
|
name <- if c_name == nullPtr
|
||||||
|
then return Nothing
|
||||||
|
else fmap Just (peekUtf8CString c_name)
|
||||||
|
touchConcr lang
|
||||||
|
return name
|
||||||
|
|
||||||
-- | List of all functions defined in the abstract syntax
|
-- | List of all functions defined in the abstract syntax
|
||||||
functions :: PGF -> [Fun]
|
functions :: PGF -> [Fun]
|
||||||
functions p =
|
functions p =
|
||||||
|
|||||||
Reference in New Issue
Block a user