summaryrefslogtreecommitdiff
path: root/stream.sig
diff options
context:
space:
mode:
authorVladimir Azarov <avm@intermediate-node.net>2025-03-24 22:37:21 +0100
committerVladimir Azarov <avm@intermediate-node.net>2025-03-24 22:37:21 +0100
commit226f58656b4b7f92f6de9a817ab9106937e061e9 (patch)
treed2e4c23e520d99c59685d18b24058f8a45def43e /stream.sig
parent87217fe5ba58f5199d30586b5d9bec104dece445 (diff)
Simplified stream
Diffstat (limited to 'stream.sig')
-rw-r--r--stream.sig31
1 files changed, 15 insertions, 16 deletions
diff --git a/stream.sig b/stream.sig
index 98cfb65..febd4b7 100644
--- a/stream.sig
+++ b/stream.sig
@@ -2,35 +2,34 @@ signature STREAM = sig
type fileId = int
type fileOffset = int
type pos = fileId * fileOffset
- type convPos = string * int * int option
-
- type filesInfo = (fileId * string * string) list
-
- exception EndOfStream
- exception EndOfFile
-
- exception LineWithoutNl
+ type ppos (* pretty pos *)
type t
+ type fileInfo
- val extractFilesInfo: t -> filesInfo
+ val recycle: t -> fileInfo
- val pos2str: convPos -> string
- val printPos: (fileId * string * string) list -> pos -> unit
+ val ppos2str: ppos -> string
+ val printPos: fileInfo -> pos -> unit
- val getchar: t -> char * t
+ val getchar: t -> char option * t
+
+ (* Will throw UngetcError, if applied at the beginning of the stream.
+ * Can be always avoided, so is not provided in sig file *)
val ungetc: t -> t
- val readline: t -> string * t
val getOffset: t -> fileOffset
val getPos: t -> pos
val getPosAfterCharRead: t -> pos
- val getPposFromPos: pos -> t -> convPos
+ val getPposFromPos: pos -> t -> ppos
+
+ (* Assumed to be called once for given pos, so will throw Unreachable on
+ * second call *)
+ val pposWithoutCol: ppos -> ppos
val getSubstr: fileOffset -> fileOffset -> t -> string
val isFirstOnLine: pos -> t -> bool
- val advanceToNewFile: t -> t
-
+ (* throws IO.Io *)
val streamInit: string -> t
end