diff options
Diffstat (limited to 'cpp.fun')
-rw-r--r-- | cpp.fun | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -91,7 +91,36 @@ functor Cpp(T: TOKENIZER): CPP = struct fun debugPrint fname = let val stream = create fname + val cache = T.S.pposCacheInit $ hd $ #fileInfo stream + + fun print' cache stream first = + let + val (tk, stream) = getToken stream + val ` = Int.toString + in + case tk of + T.NewLine => print' cache stream first + | T.EOS => () + | tk => + let + val ((line, col), cache') = T.S.pposCacheAdvance + (getLastPos stream) cache + fun printTk () = + print $ `col ^ ":" ^ T.token2str tk ^ " " + in + if T.S.pposCacheGetLine cache = line andalso not first then + printTk () + else + (if not first then print "\n" else (); + printLn $ T.S.pposCacheGetFname cache' ^ ":" ^ `line; + print "\t"; + printTk ()); + print' cache' stream false + end + end in - () + print' cache stream true; + print "\n" end + end |