summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Infra/SIO.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2015-08-10 14:12:51 +0000
committerhallgren <hallgren@chalmers.se>2015-08-10 14:12:51 +0000
commit8d6e61a8df4480385a1f2ef29a96f6a88af9e3ba (patch)
tree1da6dd617111f90f3a242e6f2f49f784926c1362 /src/compiler/GF/Infra/SIO.hs
parentd38efbaa6a2c94218bb65925bd9ad6c028dfbfd6 (diff)
gf -cshell: preliminary support for the C run-time system in the GF shell
Some C run-time functionality is now available in the GF shell, by starting GF with 'gf -cshell' or 'gf -crun'. Only limited functionality is available when running the shell in these modes: - You can only import .pgf files, not source files. - The -retain flag can not be used and the commands that require it to work are not available. - Only 18 of the 40 commands available in the usual shell have been implemented. The 'linearize' and 'parse' commands are the only ones that call the C run-time system, and they support only a limited set of options and flags. Use the 'help' commmands for details. - A new command 'generate_all', that calls PGF2.generateAll, has been added. Unfortuntaly, using it causes 'segmentation fault'. This is implemented by adding two new modules: GF.Command.Commands2 and GF.Interactive2. They are copied and modified versions of GF.Command.Commands and GF.Interactive, respectively. Code for unimplemented commands and other code that has not been adapted to the C run-time system has been left in place, but commented out, pending further work.
Diffstat (limited to 'src/compiler/GF/Infra/SIO.hs')
-rw-r--r--src/compiler/GF/Infra/SIO.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/compiler/GF/Infra/SIO.hs b/src/compiler/GF/Infra/SIO.hs
index 5ca683707..e24a6cb35 100644
--- a/src/compiler/GF/Infra/SIO.hs
+++ b/src/compiler/GF/Infra/SIO.hs
@@ -1,5 +1,6 @@
-- | Shell IO: a monad that can restrict acesss to arbitrary IO and has the
-- ability to capture output that normally would be sent to stdout.
+{-# LANGUAGE CPP #-}
module GF.Infra.SIO(
-- * The SIO monad
SIO,
@@ -11,6 +12,9 @@ module GF.Infra.SIO(
newStdGen,print,putStrLn,
-- ** Specific to GF
importGrammar,importSource,
+#ifdef C_RUNTIME
+ readPGF2,
+#endif
putStrLnFlush,runInterruptibly,lazySIO,
-- * Restricted accesss to arbitrary (potentially unsafe) IO operations
-- | If the environment variable GF_RESTRICTED is defined, these
@@ -33,6 +37,9 @@ import qualified System.Random as IO(newStdGen)
import qualified GF.Infra.UseIO as IO(getLibraryDirectory)
import qualified GF.System.Signal as IO(runInterruptibly)
import qualified GF.Command.Importing as GF(importGrammar, importSource)
+#ifdef C_RUNTIME
+import qualified PGF2
+#endif
-- * The SIO monad
@@ -96,3 +103,7 @@ lazySIO = lift1 lazyIO
importGrammar pgf opts files = lift0 $ GF.importGrammar pgf opts files
importSource opts files = lift0 $ GF.importSource opts files
+
+#ifdef C_RUNTIME
+readPGF2 = lift0 . PGF2.readPGF
+#endif