mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-02 07:42:50 -06:00
pretty printing for expressions and types
This commit is contained in:
@@ -25,6 +25,7 @@ data PgfExn
|
||||
data PgfText
|
||||
data PgfItor
|
||||
data PgfPGF
|
||||
data PgfPrintContext
|
||||
data PgfConcr
|
||||
data PgfTypeHypo
|
||||
data PgfMarshaller
|
||||
@@ -51,9 +52,15 @@ foreign import ccall "&pgf_free"
|
||||
foreign import ccall "pgf_abstract_name"
|
||||
pgf_abstract_name :: Ptr PgfPGF -> IO (Ptr PgfText)
|
||||
|
||||
foreign import ccall "pgf_print_expr"
|
||||
pgf_print_expr :: StablePtr Expr -> Ptr PgfPrintContext -> CInt -> Ptr PgfMarshaller -> IO (Ptr PgfText)
|
||||
|
||||
foreign import ccall "pgf_read_expr"
|
||||
pgf_read_expr :: Ptr PgfText -> Ptr PgfUnmarshaller -> IO (StablePtr Expr)
|
||||
|
||||
foreign import ccall "pgf_print_type"
|
||||
pgf_print_type :: StablePtr Type -> Ptr PgfPrintContext -> CInt -> Ptr PgfMarshaller -> IO (Ptr PgfText)
|
||||
|
||||
foreign import ccall "pgf_read_type"
|
||||
pgf_read_type :: Ptr PgfText -> Ptr PgfUnmarshaller -> IO (StablePtr Type)
|
||||
|
||||
@@ -105,6 +112,16 @@ peekText ptr =
|
||||
cs <- decode pptr end
|
||||
return (((toEnum . fromEnum) x) : cs)
|
||||
|
||||
newTextEx :: Int -> String -> IO (Ptr a)
|
||||
newTextEx offs s = do
|
||||
ptr <- mallocBytes (offs + (#size PgfText) + size + 1)
|
||||
let ptext = ptr `plusPtr` offs
|
||||
(#poke PgfText, size) ptext (fromIntegral size :: CSize)
|
||||
pokeUtf8CString s (ptext `plusPtr` (#const offsetof(PgfText, text)))
|
||||
return ptr
|
||||
where
|
||||
size = utf8Length s
|
||||
|
||||
newText :: String -> IO (Ptr PgfText)
|
||||
newText s = do
|
||||
ptr <- mallocBytes ((#size PgfText) + size + 1)
|
||||
|
||||
Reference in New Issue
Block a user