summaryrefslogtreecommitdiff
path: root/stream.sig
diff options
context:
space:
mode:
Diffstat (limited to 'stream.sig')
-rw-r--r--stream.sig36
1 files changed, 10 insertions, 26 deletions
diff --git a/stream.sig b/stream.sig
index 1307a60..7925285 100644
--- a/stream.sig
+++ b/stream.sig
@@ -1,49 +1,33 @@
signature STREAM = sig
type fileId = int
type fileOffset = int
- type pos = fileId * fileOffset
- type ppos (* pretty pos *)
- type pposCache
+
+ datatype pos = Pos of string * int * int
type t
- type fileInfo = fileId * string * string
- val convert: t -> fileInfo
+ exception EOF
- val ppos2str: ppos -> string
+ val pos2str: pos -> string
val getchar: t -> char option * t
+ val getcharEx: t -> char * t (* throws EOF *)
(* 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 getPos: t -> pos
- val getPosAfterCharRead: t -> pos
-
- (* pos must come from t, see pos2pposWithFI *)
- val pos2ppos: pos -> t -> ppos
- (* #id pos must be equal to fileId of fileInfo,
- * otherwise InvalidFileInfo is thrown *)
- val pos2pposWithFI: pos -> fileInfo -> ppos
-
- (* Assumed to be called once for given pos, so will throw Unreachable on
- * second call *)
- val pposWithoutCol: ppos -> ppos
+ val EOFpos: t -> pos * t
val getSubstr: fileOffset -> fileOffset -> t -> string
val getFname: t -> string
- val isFirstOnLine: pos -> t -> bool
(* both throw IO.Io *)
val create: string -> t
val createFromInstream: string -> TextIO.instream -> t
- val pposCacheInit: fileInfo -> pposCache
-
- val pposCacheGetId: pposCache -> fileId
- val pposCacheGetLine: pposCache -> int
- val pposCacheGetFname: pposCache -> string
-
- val pposCacheAdvance: pos -> pposCache -> (int * int) * pposCache
+ val getOffset: t -> fileOffset
+ val getPosRaw: fileOffset -> t -> pos * t
+ val getPos: t -> pos * t
+ val getPosAfterChar: t -> pos * t
end