diff options
author | Vladimir Azarov <avm@intermediate-node.net> | 2025-04-11 21:54:16 +0200 |
---|---|---|
committer | Vladimir Azarov <avm@intermediate-node.net> | 2025-04-11 21:54:16 +0200 |
commit | e99a8dc48ede26696be2ba75a8cb0d5122d94598 (patch) | |
tree | c3dcd1d6a9b96aaedd081f13b9dc7e7d6c07e2bd /stream.sml | |
parent | 8e2dc7712de206b87e1c46df9383c3fa1e18a43a (diff) |
#include directive
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 |