mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
add commands to add/remove concrete syntaxes
This commit is contained in:
@@ -16,10 +16,12 @@ data Command
|
||||
data TransactionCommand
|
||||
= CreateFun [Option] Fun Type
|
||||
| CreateCat [Option] Cat [Hypo]
|
||||
| CreateConcrete [Option] ConcName
|
||||
| CreateLin [Option] Fun Term
|
||||
| CreateLincat [Option] Cat Term
|
||||
| DropFun [Option] Fun
|
||||
| DropCat [Option] Cat
|
||||
| DropConcrete [Option] ConcName
|
||||
| DropLin [Option] Fun
|
||||
| DropLincat [Option] Cat
|
||||
deriving Show
|
||||
|
||||
@@ -684,10 +684,10 @@ pgfCommands = Map.fromList [
|
||||
}),
|
||||
("c", emptyCommandInfo {
|
||||
longname = "create",
|
||||
syntax = "create fun f = ..; create cat c = ..; create lin c = ..; or create lincat c = ..",
|
||||
synopsis = "Dynamically adds new functions and categories to the current grammar.",
|
||||
syntax = "create fun f = ..; create cat c = ..; create concrete l; create lin c = ..; or create lincat c = ..",
|
||||
synopsis = "Dynamically adds new functions, categories and languages to the current grammar.",
|
||||
explanation = unlines [
|
||||
"After the command you can write fun, data, cat, lin or a lincat definition.",
|
||||
"After the command you can write fun, data, cat, concrete, lin or a lincat definition.",
|
||||
"The syntax is the same as if the definition was in a module. If you want to use",
|
||||
"any operations inside lin and lincat, you should import them",
|
||||
"by using the command `i -resource <file path>`."
|
||||
@@ -700,11 +700,11 @@ pgfCommands = Map.fromList [
|
||||
}),
|
||||
("d", emptyCommandInfo {
|
||||
longname = "drop",
|
||||
syntax = "drop fun f; drop cat c; drop lin c; or drop lincat c",
|
||||
synopsis = "Dynamically removes functions and categories from the current grammar.",
|
||||
syntax = "drop fun f; drop cat c; drop concrete l; drop lin c; or drop lincat c",
|
||||
synopsis = "Dynamically removes functions, categories and languages from the current grammar.",
|
||||
explanation = unlines [
|
||||
"After the command you must specify whether you want to remove",
|
||||
"fun, data, cat, lin or a lincat definition.",
|
||||
"fun, data, cat, concrete, lin or a lincat definition.",
|
||||
"Note that if you are removing an abstract function or category,",
|
||||
"then all corresponding linearizations will be dropped as well."
|
||||
],
|
||||
|
||||
@@ -75,6 +75,13 @@ pTransactionCommand = do
|
||||
| take 1 cmd == "d" -> do
|
||||
c <- pIdent
|
||||
return (DropCat opts c)
|
||||
"concrete"
|
||||
| take 1 cmd == "c" -> do
|
||||
name <- pIdent
|
||||
return (CreateConcrete opts name)
|
||||
| take 1 cmd == "d" -> do
|
||||
name <- pIdent
|
||||
return (DropConcrete opts name)
|
||||
"lin" | take 1 cmd == "c" -> do
|
||||
f <- pIdent
|
||||
skipSpaces
|
||||
|
||||
@@ -242,6 +242,9 @@ transactionCommand (CreateCat opts c ctxt) pgf = do
|
||||
Left msg -> putStrLnE msg
|
||||
Right ty -> do lift $ modifyPGF pgf (createCategory c ctxt prob)
|
||||
return ()
|
||||
transactionCommand (CreateConcrete opts name) pgf = do
|
||||
lift $ modifyPGF pgf (createConcrete name (return ()))
|
||||
return ()
|
||||
transactionCommand (CreateLin opts f t) pgf = do
|
||||
lang <- optLang pgf opts
|
||||
lift $ modifyPGF pgf (alterConcrete lang (createLin f []))
|
||||
@@ -256,6 +259,9 @@ transactionCommand (DropFun opts f) pgf = do
|
||||
transactionCommand (DropCat opts c) pgf = do
|
||||
lift $ modifyPGF pgf (dropCategory c)
|
||||
return ()
|
||||
transactionCommand (DropConcrete opts name) pgf = do
|
||||
lift $ modifyPGF pgf (dropConcrete name)
|
||||
return ()
|
||||
transactionCommand (DropLin opts f) pgf = do
|
||||
lang <- optLang pgf opts
|
||||
lift $ modifyPGF pgf (alterConcrete lang (dropLin f))
|
||||
|
||||
Reference in New Issue
Block a user