From 945a49214bd49fb082e8f613fc68d192a1b38743 Mon Sep 17 00:00:00 2001 From: aarne Date: Fri, 5 Oct 2007 09:02:47 +0000 Subject: cleaned up new GFCC, but added RP as deprecated --- src/GF/Infra/CompactPrint.hs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/GF/Infra/CompactPrint.hs') 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 -- cgit v1.2.3