[Oberon] N-O Scanner structure confusing ?
easlab at absamail.co.za
Thu Feb 1 15:13:57 MET 2007
Lets examine how we could possibly process text after the very versatile
scanner has found a searched-for token.
The Scanner is initialised by:
OpenScanner* (VAR S: Scanner; T: Text; pos: LONGINT);
(** Open text scanner S and set it up at position pos in text T. *)
But there seems no good reason to have the 'pos' arg a VAR-par, since
it seems not to be changed ?
PROCEDURE Scan* (VAR S: Scanner);
uses the Record Reader, which allows access to its 'position' via the
function-proc 'Pos'. Ie. PROCEDURE Pos (VAR R: Reader): LONGINT;
(* Return reader's position within the text. *)
Again, why is this paramenter/arg 'Reader' a VAR-par ?
The 2 stepped fields of Reader : bufpos, off are private and inaccessible.
The fact that Scanners are descendants of Reader records, also
doesn't directly allow up-casting to allow using the Reader's
'Pos' function-proc. AFIAK ?
Obviously the compiler uses the Scanner directly to work with tokens,
ie. not characters; and then indicates character positions, eg. with the
Previously in order to delete various fields from NewsMessages, I've
used the powerfull scanner to locate the fields, while using it's
'count CRs facility". And then a re-read with the Reader using the
counted CRs to get the final char-positions to do the deleting.
That's an adsurd method ! It's time to know how the character
position of the Scanner is directly found.
Since the scanner uses 1-char-look-ahead to show the next char,
why can't it also tell the position of this char ?!
Thanks for any input,
== Chris Glur.
More information about the Oberon