diff options
| author | aarne <unknown> | 2005-11-15 10:43:32 +0000 |
|---|---|---|
| committer | aarne <unknown> | 2005-11-15 10:43:32 +0000 |
| commit | 1fd1f44fcc81149b286992dd13b3128d42c4736e (patch) | |
| tree | 26361d155c0fe4291fd49ce55d610ff156dd32d7 /examples/CLE/CF2GF.hs | |
| parent | f339b8839bcb25a57cb22baa3342032892f9be63 (diff) | |
extended cf syntax; Det experiment
Diffstat (limited to 'examples/CLE/CF2GF.hs')
| -rw-r--r-- | examples/CLE/CF2GF.hs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/CLE/CF2GF.hs b/examples/CLE/CF2GF.hs new file mode 100644 index 000000000..1bb1d6611 --- /dev/null +++ b/examples/CLE/CF2GF.hs @@ -0,0 +1,20 @@ +import Data.List (intersperse) +import Data.Char (isAlpha) + +-- to massage cf rules to funs, in order, preserving comments +-- to get cats, use pg -printer=gf + +cf2gf :: FilePath -> IO () +cf2gf file = do + ss <- readFile file >>= return . lines + mapM_ (putStrLn . mkOne) ss + +mkOne line = case words line of + fun : cat : "::=" : cats -> + let + (cats0,cats2) = span (/=";") cats + cats1 = filter (isAlpha . head) cats0 ++ [cat] + in + unwords $ [init fun, ":"] ++ intersperse "->" cats1 ++ cats2 + _ -> line +
\ No newline at end of file |
