diff options
Diffstat (limited to 'stream.sml')
-rw-r--r-- | stream.sml | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -74,17 +74,22 @@ structure Stream :> STREAM = struct fun getSubstr startOff endOff (_, _, _, contents) = String.substring (contents, startOff, endOff - startOff) - fun create fname = + fun getFname (stream: t) = #2 stream + + val lastUsedId = ref ~1 + + fun createFromInstream fname instream = let open TextIO - - val h = openIn fname - val contents = inputAll h - val () = closeIn h + val contents = inputAll instream + val () = closeIn instream in - (0, fname, 0, contents) + lastUsedId := !lastUsedId + 1; + (!lastUsedId, fname, 0, contents) end + fun create fname = createFromInstream fname (TextIO.openIn fname) + fun isFirstOnLine (_, offset) ((_, _, _, contents) : t) = let fun returnToNL ~1 = true @@ -119,6 +124,7 @@ structure Stream :> STREAM = struct offset = pos, line, col }) end + fun pposCacheGetId (cache: pposCache) = #id cache fun pposCacheGetLine (cache: pposCache) = #line cache fun pposCacheGetFname (cache: pposCache) = #fname cache end |