forked from GitHub/gf-core
haskell-bind: add bindings to graphviz rendering functions for abstract&parse trees
This commit is contained in:
@@ -23,6 +23,7 @@ module PGF2 (-- * CId
|
|||||||
Type(..), Hypo, functionType,
|
Type(..), Hypo, functionType,
|
||||||
-- * Trees
|
-- * Trees
|
||||||
Expr,Fun,readExpr,showExpr,mkApp,unApp,mkStr,
|
Expr,Fun,readExpr,showExpr,mkApp,unApp,mkStr,
|
||||||
|
graphvizAbstractTree,graphvizParseTree,
|
||||||
-- * Morphology
|
-- * Morphology
|
||||||
MorphoAnalysis, lookupMorpho, fullFormLexicon,
|
MorphoAnalysis, lookupMorpho, fullFormLexicon,
|
||||||
-- * Exceptions
|
-- * Exceptions
|
||||||
@@ -272,6 +273,27 @@ showExpr e =
|
|||||||
peekCString s
|
peekCString s
|
||||||
|
|
||||||
|
|
||||||
|
graphvizAbstractTree :: PGF -> Expr -> String
|
||||||
|
graphvizAbstractTree p e =
|
||||||
|
unsafePerformIO $
|
||||||
|
withGuPool $ \tmpPl ->
|
||||||
|
do (sb,out) <- newOut tmpPl
|
||||||
|
exn <- gu_new_exn tmpPl
|
||||||
|
pgf_graphviz_abstract_tree (pgf p) (expr e) out exn
|
||||||
|
s <- gu_string_buf_freeze sb tmpPl
|
||||||
|
peekCString s
|
||||||
|
|
||||||
|
|
||||||
|
graphvizParseTree :: Concr -> Expr -> String
|
||||||
|
graphvizParseTree c e =
|
||||||
|
unsafePerformIO $
|
||||||
|
withGuPool $ \tmpPl ->
|
||||||
|
do (sb,out) <- newOut tmpPl
|
||||||
|
exn <- gu_new_exn tmpPl
|
||||||
|
pgf_graphviz_parse_tree (concr c) (expr e) out exn
|
||||||
|
s <- gu_string_buf_freeze sb tmpPl
|
||||||
|
peekCString s
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Functions using Concr
|
-- Functions using Concr
|
||||||
-- Morpho analyses, parsing & linearization
|
-- Morpho analyses, parsing & linearization
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
module PGF2.FFI where
|
module PGF2.FFI where
|
||||||
|
|
||||||
import Foreign.C
|
import Foreign.C
|
||||||
import Foreign.C.String
|
--import Foreign.C.String
|
||||||
import Foreign.Ptr
|
import Foreign.Ptr
|
||||||
import Foreign.ForeignPtr
|
import Foreign.ForeignPtr
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
@@ -206,3 +206,10 @@ foreign import ccall "pgf/pgf.h pgf_print"
|
|||||||
|
|
||||||
foreign import ccall "pgf/expr.h pgf_read_expr"
|
foreign import ccall "pgf/expr.h pgf_read_expr"
|
||||||
pgf_read_expr :: Ptr GuIn -> Ptr GuPool -> Ptr GuExn -> IO PgfExpr
|
pgf_read_expr :: Ptr GuIn -> Ptr GuPool -> Ptr GuExn -> IO PgfExpr
|
||||||
|
|
||||||
|
|
||||||
|
foreign import ccall "pgf/graphviz.h pgf_graphviz_abstract_tree"
|
||||||
|
pgf_graphviz_abstract_tree :: Ptr PgfPGF -> PgfExpr -> Ptr GuOut -> Ptr GuExn -> IO ()
|
||||||
|
|
||||||
|
foreign import ccall "pgf/graphviz.h pgf_graphviz_parse_tree"
|
||||||
|
pgf_graphviz_parse_tree :: Ptr PgfConcr -> PgfExpr -> Ptr GuOut -> Ptr GuExn -> IO ()
|
||||||
|
|||||||
Reference in New Issue
Block a user