diff options
| author | aarne <aarne@cs.chalmers.se> | 2007-10-05 09:02:47 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2007-10-05 09:02:47 +0000 |
| commit | 945a49214bd49fb082e8f613fc68d192a1b38743 (patch) | |
| tree | 4d6582426ea0bb5458b12a74a1c7c86fc0981553 /src/GF/Infra/CompactPrint.hs | |
| parent | cc104236df63dafebaf87612aa379156cf914063 (diff) | |
cleaned up new GFCC, but added RP as deprecated
Diffstat (limited to 'src/GF/Infra/CompactPrint.hs')
| -rw-r--r-- | src/GF/Infra/CompactPrint.hs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/GF/Infra/CompactPrint.hs b/src/GF/Infra/CompactPrint.hs index 56aaf4d64..eb964809f 100644 --- a/src/GF/Infra/CompactPrint.hs +++ b/src/GF/Infra/CompactPrint.hs @@ -1,11 +1,19 @@ module GF.Infra.CompactPrint where import Data.Char -compactPrint = tail . concat . map spaceIf . words +compactPrint = compactPrintCustom keywordGF (const False) -spaceIf w = case w of - _ | keyword w -> "\n" ++ w +compactPrintGFCC = compactPrintCustom (const False) keywordGFCC + +compactPrintCustom pre post = tail . concat . map (spaceIf pre post) . words + +spaceIf pre post w = case w of + _ | pre w -> "\n" ++ w + _ | post w -> w ++ "\n" c:cs | isAlpha c || isDigit c -> " " ++ w _ -> w -keyword w = elem w ["cat","fun","lin","lincat","lindef","oper","param"] +keywordGF w = elem w ["cat","fun","lin","lincat","lindef","oper","param"] +keywordGFCC w = + last w == ';' || + elem w ["flags","fun","cat","lin","oper","lincat","lindef","printname"]
\ No newline at end of file |
