pprMain []      = nil;
pprMain (s : x) = nil <> p s x <> nil;

p s []     = pprInt s;
p s (a:x)  = pprInt s <> sep <> p a x ; 

pprInt s = text (bij i2a s @@ re "[0-9]+");

sep = space <+ comments;
comments = nil <+ (nil <> comment <> comments);
  
-- sp = text " " <+ charOf (spaceChars `butnot` chars " ");
-- nil = text "" <+ ((comment <+ sp) <> nil) ;

space = (text " " <+ charOf (spaceChars `butnot` chars " ")) <> nil;
nil   = text "" <+ space;
comment      = lineComment <+ blockComment;
lineComment  = text "--" <> nbstring;
nbstring = text "" <+ charOf (allChars `butnot` chars "\n") <> nbstring;
                      
blockComment = text "{-" <> blockCommentP <> text "-}";
blockCommentP = 
    text ""
    <+
    charOf (allChars `butnot` (chars "{" `orelse` chars "\\-")) <> blockCommentP
    <+ 
    charOf (chars "{") <> charOf (allChars `butnot` chars "\\-") <> blockCommentP
    <+
    charOf (chars "\\-") <> charOf (allChars `butnot` chars "}") <> blockCommentP
    <+
    text "{-" <> blockCommentP <> text "-}" <> blockCommentP
              

