diff options
Diffstat (limited to 'stream.sml')
-rw-r--r-- | stream.sml | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -6,6 +6,7 @@ structure Stream :> STREAM = struct type fileInfo = fileId * string * string exception UngetcError + exception InvalidFileInfo fun ppos2str (pos, line, col) = let @@ -56,12 +57,17 @@ structure Stream :> STREAM = struct fun getPosAfterCharRead (fid, _, off, _) = (fid, off - 1) - fun pos2ppos (_, pos) (_, fname, _, contents) = - let - val (line, col) = calcFilePos contents pos - in - (fname, line, SOME col) - end + fun pos2pposWithFI (id, pos) (id', fname, contents) = + if id <> id' then + raise InvalidFileInfo + else + let + val (line, col) = calcFilePos contents pos + in + (fname, line, SOME col) + end + + fun pos2ppos pos stream = pos2pposWithFI pos (convert stream) fun pposWithoutCol (fname, line, SOME _) = (fname, line, NONE) | pposWithoutCol (_, _, NONE) = raise Unreachable @@ -71,7 +77,7 @@ structure Stream :> STREAM = struct fun getSubstr startOff endOff (_, _, _, contents) = String.substring (contents, startOff, endOff - startOff) - fun streamInit fname = + fun create fname = let open TextIO |