improved gfe; sloc stats

This commit is contained in:
aarne
2005-06-03 07:29:37 +00:00
parent f0e13dd29f
commit 2e0b40f138
3 changed files with 343 additions and 14 deletions

View File

@@ -50,32 +50,44 @@ mkConcrete file = do
let parser cat = errVal ([],"No parse") .
optParseArgErrMsg (options [newMParser, firstCat cat, beVerbose]) gr
let morpho = isKnownWord gr
writeFile (suffixFile "gf" (justModuleName file)) $ unlines $
map (mkCnc parser morpho) cont
let out = suffixFile "gf" $ justModuleName file
mapM_ (mkCnc out parser morpho) cont
getResPath :: [String] -> String
getResPath s = case head (dropWhile (all isSpace) s) of
'-':'-':'#':path -> reverse (takeWhile (not . (=='=')) (reverse path))
_ -> error "first line must be --# -resource=<PATH>"
mkCnc :: (String -> String -> ([Tree],String)) -> (String -> Bool) -> String -> String
mkCnc parser morpho line = case words line of
"lin" : rest -> mkLinRule rest
_ -> line
mkCnc :: FilePath -> (String -> String -> ([Tree],String)) -> (String -> Bool) ->
String -> IO ()
mkCnc out parser morpho line = do
let (res,msg) = mkCncLine parser morpho line
appendFile out res
appendFile out "\n"
ifNull (return ()) putStrLnFlush msg
mkCncLine :: (String -> String -> ([Tree],String)) -> (String -> Bool) ->
String -> (String,String)
mkCncLine parser morpho line = case words line of
"lin" : rest | elem "in" rest -> mkLinRule "lin" rest
"oper" : rest | elem "in" rest -> mkLinRule "oper" rest
_ -> (line,[])
where
mkLinRule s =
mkLinRule key s =
let
(pre,str) = span (/= "in") s
([cat],rest) = splitAt 1 $ tail str
lin = init (tail (unwords (init rest))) -- unquote
def
def
| last pre /= "=" = line -- ordinary lin rule
| otherwise = case parser cat lin of
([t],_) -> "lin " ++ unwords pre +++ prt_ (tree2exp t) +++ ";"
(t:_,_) -> "lin " ++ unwords pre +++ prt_ (tree2exp t) +++ "{- AMBIGUOUS -} ;"
([t],_) -> ind ++ key +++ unwords pre +++ prt_ (tree2exp t) +++ ";"
(t:_,_) -> ind ++ key +++ unwords pre +++ prt_ (tree2exp t) +++ ";"
+++ "-- AMBIGUOUS"
([],msg) -> "{-" ++ line ++++ morph lin ++++ "-}"
in
def
(def,def)
morph s = case [w | w <- words s, not (morpho w)] of
[] -> ""
ws -> "unknown words: " ++ unwords ws
ind = takeWhile isSpace line