mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
vt -api with conversion to resource API names
This commit is contained in:
@@ -20,6 +20,7 @@ import PGF.Macros
|
|||||||
import PGF.Data ----
|
import PGF.Data ----
|
||||||
import PGF.Morphology
|
import PGF.Morphology
|
||||||
import PGF.Printer
|
import PGF.Printer
|
||||||
|
import PGF.ToAPI
|
||||||
import PGF.Probabilistic -- (getProbsFromFile,prProbabilities,defaultProbabilities)
|
import PGF.Probabilistic -- (getProbsFromFile,prProbabilities,defaultProbabilities)
|
||||||
import PGF.Generate (generateRandomFrom) ----
|
import PGF.Generate (generateRandomFrom) ----
|
||||||
import PGF.Tree (Tree(Fun), expr2tree, tree2expr)
|
import PGF.Tree (Tree(Fun), expr2tree, tree2expr)
|
||||||
@@ -851,6 +852,11 @@ allCommands env@(pgf, mos) = Map.fromList [
|
|||||||
exec = \opts es ->
|
exec = \opts es ->
|
||||||
if isOpt "mk" opts
|
if isOpt "mk" opts
|
||||||
then return $ fromString $ unlines $ map (tree2mk pgf) es
|
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
|
else do
|
||||||
let funs = not (isOpt "nofun" opts)
|
let funs = not (isOpt "nofun" opts)
|
||||||
let cats = not (isOpt "nocat" 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"
|
"p \"hello\" | vt -view=\"open\" -- parse a string and display trees on a Mac"
|
||||||
],
|
],
|
||||||
options = [
|
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"),
|
("nofun","don't show functions but only categories"),
|
||||||
("nocat","don't show categories but only functions")
|
("nocat","don't show categories but only functions")
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module PGF.ToAPI
|
module PGF.ToAPI
|
||||||
(stringToAPI,exprToAPI)
|
(stringToAPI,exprToAPI,exprToAPIIO)
|
||||||
where
|
where
|
||||||
|
|
||||||
import PGF.Expr
|
import PGF.Expr
|
||||||
@@ -14,6 +14,10 @@ import qualified Data.Map as Map
|
|||||||
import PGF.Signature
|
import PGF.Signature
|
||||||
|
|
||||||
|
|
||||||
|
--- this will be changed
|
||||||
|
exprToAPIIO :: Expr -> IO String
|
||||||
|
exprToAPIIO = exprToAPI -- return . exprToAPI
|
||||||
|
|
||||||
|
|
||||||
-- intermediate structure for representing the translated expression
|
-- intermediate structure for representing the translated expression
|
||||||
data APIfunc = BasicFunc String | AppFunc String [APIfunc] | NoAPI
|
data APIfunc = BasicFunc String | AppFunc String [APIfunc] | NoAPI
|
||||||
|
|||||||
Reference in New Issue
Block a user