summaryrefslogtreecommitdiff
path: root/stream.sml
diff options
context:
space:
mode:
authorVladimir Azarov <avm@intermediate-node.net>2025-04-11 21:54:16 +0200
committerVladimir Azarov <avm@intermediate-node.net>2025-04-11 21:54:16 +0200
commite99a8dc48ede26696be2ba75a8cb0d5122d94598 (patch)
treec3dcd1d6a9b96aaedd081f13b9dc7e7d6c07e2bd /stream.sml
parent8e2dc7712de206b87e1c46df9383c3fa1e18a43a (diff)
#include directive
Diffstat (limited to 'stream.sml')
-rw-r--r--stream.sml18
1 files changed, 12 insertions, 6 deletions
diff --git a/stream.sml b/stream.sml
index a6afa31..4134293 100644
--- a/stream.sml
+++ b/stream.sml
@@ -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