summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraarne <aarne@chalmers.se>2010-12-06 09:53:04 +0000
committeraarne <aarne@chalmers.se>2010-12-06 09:53:04 +0000
commit00111b10c193ccca6c37b356bf2d4ce67cb69975 (patch)
treecdff75edf7fd7542122304172583f835cbb3e4a4
parent6268c2d7d9c87720dfcecf9dde12fb7443bf3200 (diff)
vt -api with conversion to resource API names
-rw-r--r--src/compiler/GF/Command/Commands.hs9
-rw-r--r--src/runtime/haskell/PGF/ToApi.hs6
2 files changed, 13 insertions, 2 deletions
diff --git a/src/compiler/GF/Command/Commands.hs b/src/compiler/GF/Command/Commands.hs
index d320396d5..c82ee79af 100644
--- a/src/compiler/GF/Command/Commands.hs
+++ b/src/compiler/GF/Command/Commands.hs
@@ -20,6 +20,7 @@ import PGF.Macros
import PGF.Data ----
import PGF.Morphology
import PGF.Printer
+import PGF.ToAPI
import PGF.Probabilistic -- (getProbsFromFile,prProbabilities,defaultProbabilities)
import PGF.Generate (generateRandomFrom) ----
import PGF.Tree (Tree(Fun), expr2tree, tree2expr)
@@ -851,6 +852,11 @@ allCommands env@(pgf, mos) = Map.fromList [
exec = \opts es ->
if isOpt "mk" opts
then return $ fromString $ unlines $ map (tree2mk pgf) es
+ else if isOpt "api" opts
+ then do
+ ss <- mapM exprToAPIIO es
+ mapM_ putStrLn ss
+ return void
else do
let funs = not (isOpt "nofun" opts)
let cats = not (isOpt "nocat" opts)
@@ -869,7 +875,8 @@ allCommands env@(pgf, mos) = Map.fromList [
"p \"hello\" | vt -view=\"open\" -- parse a string and display trees on a Mac"
],
options = [
- ("mk", "show the tree with function names converted to 'mkC' with value cats C"),
+ ("api", "show the tree with function names converted to 'mkC' with value cats C"),
+ ("mk", "similar to -api, deprecated"),
("nofun","don't show functions but only categories"),
("nocat","don't show categories but only functions")
],
diff --git a/src/runtime/haskell/PGF/ToApi.hs b/src/runtime/haskell/PGF/ToApi.hs
index 41ccb2248..e22132c34 100644
--- a/src/runtime/haskell/PGF/ToApi.hs
+++ b/src/runtime/haskell/PGF/ToApi.hs
@@ -1,5 +1,5 @@
module PGF.ToAPI
- (stringToAPI,exprToAPI)
+ (stringToAPI,exprToAPI,exprToAPIIO)
where
import PGF.Expr
@@ -14,6 +14,10 @@ import qualified Data.Map as Map
import PGF.Signature
+--- this will be changed
+exprToAPIIO :: Expr -> IO String
+exprToAPIIO = exprToAPI -- return . exprToAPI
+
-- intermediate structure for representing the translated expression
data APIfunc = BasicFunc String | AppFunc String [APIfunc] | NoAPI