mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-24 03:52:50 -06:00
added commands create cat & drop cat
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
module GF.Command.Abstract(module GF.Command.Abstract,Expr,showExpr,Literal(..),Term) where
|
||||
|
||||
import PGF2(Expr,showExpr,Literal(..),Type)
|
||||
import PGF2
|
||||
import GF.Grammar.Grammar(Term)
|
||||
|
||||
type Ident = String
|
||||
@@ -14,8 +14,10 @@ data Command
|
||||
deriving Show
|
||||
|
||||
data TransactionCommand
|
||||
= CreateFun [Option] Ident Type
|
||||
| DropFun [Option] Ident
|
||||
= CreateFun [Option] Fun Type
|
||||
| CreateCat [Option] Cat [Hypo]
|
||||
| DropFun [Option] Fun
|
||||
| DropCat [Option] Cat
|
||||
deriving Show
|
||||
|
||||
data Option
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module GF.Command.Parse(readCommandLine, readTransactionCommand, pCommand) where
|
||||
|
||||
import PGF(pExpr,pIdent)
|
||||
import PGF2(readType)
|
||||
import PGF2(readType,readContext)
|
||||
import GF.Grammar.Parser(runPartial,pTerm)
|
||||
import GF.Command.Abstract
|
||||
|
||||
@@ -63,6 +63,16 @@ pTransactionCommand = do
|
||||
| take 1 cmd == "d" -> do
|
||||
f <- pIdent
|
||||
return (DropFun opts f)
|
||||
"cat" | take 1 cmd == "c" -> do
|
||||
c <- pIdent
|
||||
skipSpaces
|
||||
ctxt <- readS_to_P (\s -> case readContext s of
|
||||
Just ty -> [(ty,"")]
|
||||
Nothing -> [])
|
||||
return (CreateCat opts c ctxt)
|
||||
| take 1 cmd == "d" -> do
|
||||
c <- pIdent
|
||||
return (DropCat opts c)
|
||||
_ -> pfail
|
||||
|
||||
pOption = do
|
||||
|
||||
Reference in New Issue
Block a user