SUMMARY: MODULE | CLASS | TYPE | PROC | VAR | CONST | DETAIL: TYPE | PROC | VAR | CONST |
This is a port of the writer part of TextRider to IO. Reader and scanner were dropped. Don't use the riders with non-blocking channels.
Ascii CharClass Exception IO LRealStr Object Object
Class List | |
OverflowError | Raised if the parsed datatype has correct syntax but it interpetation is not valid, because of numerical overflow or similar reason. |
Reader | |
Writer |
Class Summary: OverflowError [Detail] | |
+---Exception.Exception | +---Exception.Checked | +---IO.Error | +--IO:TextRider.OverflowError Raised if the parsed datatype has correct syntax but it interpetation is not valid, because of numerical overflow or similar reason. | |
Constructor Summary | |
NewOverflowError(STRING): OverflowError | |
Inherited Methods | |
Class Summary: Reader [Detail] | |
+--IO:TextRider.Reader | |
Field Summary | |
channel-: ByteChannel The channel on which this reader is operating. | |
Constructor Summary | |
ConnectReader(ByteChannel): Reader Create a new instance of Reader that is initialized with IO.ByteChannel ch. | |
Method Summary | |
[AquireBufferWithSize](LONGINT) | |
[ConsumeWhiteSpace]() | |
INIT(ByteChannel) Initializes an already allocated Reader with the IO.ByteChannel ch. | |
ReadBool(VAR BOOLEAN) Sets `bool=TRUE' if input equals `TRUE', and `bool=FALSE' if input equals `FALSE'. | |
ReadChar(VAR CHAR) Read a character. | |
ReadHex(VAR LONGINT) Reads a Oberon-2 hex value. | |
ReadIdentifier(VAR ARRAY OF CHAR) Reads an Oberon-2 identifier. | |
ReadInt(VAR INTEGER) See Reader.ReadLInt. | |
ReadLInt(VAR LONGINT) Returns the long integer constant lint at the current position according to the format `IntConst = [whitespace] ["+"|"-"] digit'. | |
ReadLine(VAR ARRAY OF CHAR) Reads a sequence of characters into s; reading continues until an end-of-line character is encountered, the array s is full, or r reaches the end of the channel. | |
[ReadLineBuffer]() | |
ReadLn() This method reads and discards all characters up to and including the next end-of-line character. | |
ReadSInt(VAR SHORTINT) See Reader.ReadLInt. | |
ReadString(VAR ARRAY OF CHAR) Reads in a sequence of characters enclosed in single (') or double (") quote marks. | |
SetEOL(SHORTINT) Define which character token is interpreted as line end. |
Class Summary: Writer [Detail] | |
+--IO:TextRider.Writer | |
Field Summary | |
channel-: ByteChannel The channel on which this writer is operating. | |
error-: Error If any of the write methods encounters an error, then the corresponding exception is stored here. | |
Constructor Summary | |
ConnectWriter(ByteChannel): Writer | |
Method Summary | |
INIT(ByteChannel) | |
SetEol(ARRAY OF CHAR, INTEGER) Sets new end of line marker. | |
WriteBool(BOOLEAN) | |
WriteChar(CHAR) | |
WriteHex(LONGINT, LONGINT) | |
WriteInt(INTEGER, LONGINT) | |
WriteLInt(LONGINT, LONGINT) | |
WriteLReal(LONGREAL, LONGINT, LONGINT) Writes the value lreal in the format produced by LRealStr.RealToFloat. | |
WriteLRealEng(VAR LONGREAL, LONGINT, LONGINT) Writes the value lreal in the format produced by LRealStr.RealToEng. | |
WriteLRealFix(VAR LONGREAL, LONGINT, LONGINT) Writes the value lreal in the format produced by LRealStr.RealToFixed. | |
WriteLn() Write a newline. | |
WriteObject(Object) | |
WriteReal(REAL, LONGINT, LONGINT) As Writer.WriteLReal. | |
WriteRealEng(REAL, LONGINT, LONGINT) As Writer.WriteLRealEng. | |
WriteRealFix(REAL, LONGINT, LONGINT) As Writer.WriteLRealFix. | |
WriteSInt(SHORTINT, LONGINT) | |
WriteSet(SET) Write s in Oberon-2 set notation. | |
WriteString(ARRAY OF CHAR) | |
WriteStringRegion(ARRAY OF CHAR, LONGINT, LONGINT) |
Type Summary | |
[Buffer] = POINTER TO ARRAY OF CHAR |
Procedure Summary | |
NewProtocolError(STRING): ProtocolError | |
RaiseOverflowError(STRING) | |
RaiseProtocolError(STRING) |
Constant Summary | |
eolCR The EOL token is a single Ascii.cr. | |
eolCRLF The EOL token is a single Ascii.cr+Ascii.lf. | |
eolLF The EOL token is a single Ascii.lf. | |
maxLengthEol Maximum length of an end of line character sequence. |
Class Detail: OverflowError |
Constructor Detail |
PROCEDURE NewOverflowError(msg: STRING): OverflowError
Class Detail: Reader |
Field Detail |
FIELD channel-: ByteChannel
The channel on which this reader is operating.
Constructor Detail |
PROCEDURE ConnectReader(ch: ByteChannel): Reader
Create a new instance of Reader that is initialized with IO.ByteChannel ch.
Pre-condition: ch is in blocking mode.
Method Detail |
PROCEDURE (r: Reader) [AquireBufferWithSize](size: LONGINT)
PROCEDURE (r: Reader) [ConsumeWhiteSpace]() RAISES Error;
PROCEDURE (r: Reader) INIT(ch: ByteChannel)
Initializes an already allocated Reader with the IO.ByteChannel ch.
Pre-condition: ch is in blocking mode.
PROCEDURE (r: Reader) ReadBool(VAR bool: BOOLEAN) RAISES Error;
Sets `bool=TRUE' if input equals `TRUE', and `bool=FALSE' if input equals `FALSE'. If no bool value is available a IO.FormatError exception is raised.
Pre-condition: `input=[whitespace] ["TRUE"|"FALSE"]'
PROCEDURE (r: Reader) ReadChar(VAR ch: CHAR) RAISES Error;
Read a character. "End of line" tokens are normalized to Ascii.lf.
Note: If no character is available a IO.FormatError exception is be raised.
PROCEDURE (r: Reader) ReadHex(VAR int: LONGINT) RAISES Error;
Reads a Oberon-2 hex value.
If no hex number is available a IO.FormatError exception is raised.
Pre-condition: `input = [whitespace] digit {hexdigit}'.
PROCEDURE (r: Reader) ReadIdentifier(VAR s: ARRAY OF CHAR) RAISES Error;
Reads an Oberon-2 identifier.
If s is not large enough to hold the entire input, an OverflowError exception is generated. If no identifier is available a IO.FormatError exception is raised.
Pre-condition: `input = [whitespace] letter {letter | digit}'.
s must a least have a size of 2.
PROCEDURE (r: Reader) ReadInt(VAR int: INTEGER) RAISES Error;
See Reader.ReadLInt.
PROCEDURE (r: Reader) ReadLInt(VAR lint: LONGINT) RAISES Error;
Returns the long integer constant lint at the current position according to the format `IntConst = [whitespace] ["+"|"-"] digit'.
If no integer is available a IO.FormatError exception is raised. If the parsed value is too big an OverflowError is raised.
PROCEDURE (r: Reader) ReadLine(VAR s: ARRAY OF CHAR) RAISES Error;
Reads a sequence of characters into s; reading continues until an end-of-line character is encountered, the array s is full, or r reaches the end of the channel. The end-of-line character is discarded and s is always terminated with 0X. If r is already positioned at an end-of-line character, s returns as an empty string.
s returns with the sequence of characters that have been read so far (terminated by 0X). s must be big enough to hold the line, or a IO.FormatError exception is raised.
Reading past the end of file causes a IO.FormatError exception. The content of s is undefined in this case.
Caution: If reading multiple lines of input and an integer, real, etc. has just been read, the channel may be positioned at a eol character and this method will return an empty string.
PROCEDURE (r: Reader) [ReadLineBuffer]() RAISES Error;
PROCEDURE (r: Reader) ReadLn() RAISES Error;
This method reads and discards all characters up to and including the next end-of-line character.
PROCEDURE (r: Reader) ReadSInt(VAR sint: SHORTINT) RAISES Error;
See Reader.ReadLInt.
PROCEDURE (r: Reader) ReadString(VAR s: ARRAY OF CHAR) RAISES Error;
Reads in a sequence of characters enclosed in single (') or double (") quote marks. The opening quote must be the same as the closing quote and must not occur within the string. Characters are read until the terminating quote mark is encountered, an invalid character is read (end-of-line is always considered invalid), there are no more characters available in the channel, or the string s is full. s is always terminated with 0X.
Strings without a terminating quote generate a IO.FormatError exception. If s is not large enough to hold the entire input, a OverflowError exception is generated.
If the strings contains illegal characters (`char<" "') a IO.FormatError exception is generated.
Upon encountering an error, the value of s is undefined.
Pre-condition: `input = [whitespace] '"' {char} '"' | [whitespace] "'" {char} "'"'.
s must at least have a size of 1.
PROCEDURE (r: Reader) SetEOL(type: SHORTINT)
Define which character token is interpreted as line end. Currently available are eolLF, which is in general used by UNIX, eolCR, which is used by Mac OS, and eolCRLF, which is used by DOS, Windows and various text based network protocols.
Class Detail: Writer |
Field Detail |
FIELD channel-: ByteChannel
The channel on which this writer is operating.
FIELD error-: Error
If any of the write methods encounters an error, then the corresponding exception is stored here. This field is sticky. That is, is stays NIL until the first error, and it keeps the first error's exception.
Constructor Detail |
PROCEDURE ConnectWriter(ch: ByteChannel): Writer
Pre-condition: ch is in blocking mode.
Method Detail |
PROCEDURE (w: Writer) INIT(ch: ByteChannel)
PROCEDURE (w: Writer) SetEol(marker: ARRAY OF CHAR; markerLen: INTEGER)
Sets new end of line marker. If the passed string marker does not fit into the writer's field `w.eol', then nothing is done. The empty marker is permitted. The default value for newly created writer is CharClass.systemEol.
Pre-condition: (0 <= markerLen < LEN (marker)) & (markerLen <= maxLengthEol)
PROCEDURE (w: Writer) WriteBool(bool: BOOLEAN)
PROCEDURE (w: Writer) WriteChar(ch: CHAR)
PROCEDURE (w: Writer) WriteHex(lint: LONGINT; d: LONGINT)
PROCEDURE (w: Writer) WriteInt(int: INTEGER; n: LONGINT)
PROCEDURE (w: Writer) WriteLInt(lint: LONGINT; n: LONGINT)
PROCEDURE (w: Writer) WriteLReal(lreal: LONGREAL; n: LONGINT; k: LONGINT)
Writes the value lreal in the format produced by LRealStr.RealToFloat.
PROCEDURE (w: Writer) WriteLRealEng(VAR lreal: LONGREAL; n: LONGINT; k: LONGINT)
Writes the value lreal in the format produced by LRealStr.RealToEng.
PROCEDURE (w: Writer) WriteLRealFix(VAR lreal: LONGREAL; n: LONGINT; k: LONGINT)
Writes the value lreal in the format produced by LRealStr.RealToFixed.
PROCEDURE (w: Writer) WriteLn()
Write a newline.
PROCEDURE (w: Writer) WriteObject(obj: Object)
PROCEDURE (w: Writer) WriteReal(real: REAL; n: LONGINT; k: LONGINT)
PROCEDURE (w: Writer) WriteRealEng(real: REAL; n: LONGINT; k: LONGINT)
PROCEDURE (w: Writer) WriteRealFix(real: REAL; n: LONGINT; k: LONGINT)
PROCEDURE (w: Writer) WriteSInt(sint: SHORTINT; n: LONGINT)
PROCEDURE (w: Writer) WriteSet(s: SET)
Write s in Oberon-2 set notation.
PROCEDURE (w: Writer) WriteString(s: ARRAY OF CHAR)
PROCEDURE (w: Writer) WriteStringRegion(s: ARRAY OF CHAR; start: LONGINT; end: LONGINT)
Type Detail |
TYPE [Buffer] = POINTER TO ARRAY OF CHAR
Procedure Detail |
PROCEDURE NewProtocolError(msg: STRING): ProtocolError
PROCEDURE RaiseOverflowError(msg: STRING) RAISES OverflowError;
PROCEDURE RaiseProtocolError(msg: STRING) RAISES ProtocolError;
Constant Detail |
CONST eolCR
The EOL token is a single Ascii.cr.
CONST eolCRLF
CONST eolLF
The EOL token is a single Ascii.lf.
CONST maxLengthEol
Maximum length of an end of line character sequence. This value is system dependent, and always larger or equal to 2.