mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
fixed command abbreviations in GFI
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
module GF.Command.Interpreter (
|
module GF.Command.Interpreter (
|
||||||
CommandEnv (..),
|
CommandEnv (..),
|
||||||
mkCommandEnv,
|
mkCommandEnv,
|
||||||
interpretCommandLine
|
interpretCommandLine,
|
||||||
|
getCommandOp
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import GF.Command.Commands
|
import GF.Command.Commands
|
||||||
@@ -71,11 +72,11 @@ interpret env trees0 comm = case lookCommand co comms of
|
|||||||
-- analyse command parse tree to a uniform datastructure, normalizing comm name
|
-- analyse command parse tree to a uniform datastructure, normalizing comm name
|
||||||
getCommand :: Command -> [Exp] -> (String,[Option],[Exp])
|
getCommand :: Command -> [Exp] -> (String,[Option],[Exp])
|
||||||
getCommand co ts = case co of
|
getCommand co ts = case co of
|
||||||
Command c opts (AExp t) -> (getOp c,opts,[t]) -- ignore piped
|
Command c opts (AExp t) -> (getCommandOp c,opts,[t]) -- ignore piped
|
||||||
Command c opts ANoArg -> (getOp c,opts,ts) -- use piped
|
Command c opts ANoArg -> (getCommandOp c,opts,ts) -- use piped
|
||||||
where
|
|
||||||
-- abbreviation convention from gf
|
-- abbreviation convention from gf commands
|
||||||
getOp s = case break (=='_') s of
|
getCommandOp s = case break (=='_') s of
|
||||||
(a:_,_:b:_) -> [a,b] -- axx_byy --> ab
|
(a:_,_:b:_) -> [a,b] -- axx_byy --> ab
|
||||||
_ -> case s of
|
_ -> case s of
|
||||||
[a,b] -> s -- ab --> ab
|
[a,b] -> s -- ab --> ab
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ pCommand = do
|
|||||||
cmd <- pIdent
|
cmd <- pIdent
|
||||||
RP.skipSpaces
|
RP.skipSpaces
|
||||||
opts <- RP.sepBy pOption RP.skipSpaces
|
opts <- RP.sepBy pOption RP.skipSpaces
|
||||||
-- opts <- RP.many pOption
|
|
||||||
arg <- RP.option ANoArg (fmap AExp (pExp False))
|
arg <- RP.option ANoArg (fmap AExp (pExp False))
|
||||||
return (Command cmd opts arg)
|
return (Command cmd opts arg)
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,11 @@ loop opts gfenv0 = do
|
|||||||
cpu' <- getCPUTime
|
cpu' <- getCPUTime
|
||||||
putStrLnFlush (show ((cpu' - cputime gfenv') `div` 1000000000) ++ " msec")
|
putStrLnFlush (show ((cpu' - cputime gfenv') `div` 1000000000) ++ " msec")
|
||||||
loop opts $ gfenv' {cputime = cpu'}
|
loop opts $ gfenv' {cputime = cpu'}
|
||||||
case words s of
|
let
|
||||||
|
pwords = case words s of
|
||||||
|
w:ws -> getCommandOp w :ws
|
||||||
|
ws -> ws
|
||||||
|
case pwords of
|
||||||
-- special commands, requiring source grammar in env
|
-- special commands, requiring source grammar in env
|
||||||
"!":ws -> do
|
"!":ws -> do
|
||||||
system $ unwords ws
|
system $ unwords ws
|
||||||
|
|||||||
Reference in New Issue
Block a user