From 52a6f8656e8a600a2c59fa2802fb46fafb30de45 Mon Sep 17 00:00:00 2001 From: Vladimir Azarov Date: Mon, 12 May 2025 01:51:27 +0200 Subject: Object-like macros --- stream.sig | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) (limited to 'stream.sig') 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 -- cgit v1.2.3