[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: TextRider.ReadString not require quotes
- To: ooc-list@informatik.uni-kl.de
- Subject: Re: TextRider.ReadString not require quotes
- From: Ian Rae <ianrae@istar.ca>
- Date: Sun, 28 Jun 1998 01:28:35 -0400
- MMDF-Warning: Parse error in original version of preceding line at uklirb.informatik.uni-kl.de
> From: Michael van Acken <mvacken@t-online.de>
> > From: Ian Rae <ianrae@istar.ca>
> > While we're working on TextRider, here's a suggestion:
> >
> > Could an option be added that dropped the requirement
> > for strings to be enclosed in single or double quotes in
> > ReadString?
> >
> > When enabled, ReadString and WriteString would be
> > symmetric.
>
> You must provide a specification for your strings, e.g. a regular
> expression. Then you should reconsider if the result is truely
> symmetric.
>
Darn. You're right. I was thinking ReadString should tokenize
{ non-whitespace chars } but that still wouldn't be symmetric.
> > More importantly, one would be able to use TextRider
> > to parse ordinary tokens (i.e. anything separated by
> > whitespace). For example, I wanted to read a list
> > of module names, selected in a Bbox text
> >
> > TextRider.Mod In.Mod Out.Mod
> >
> > Amazingly one could not easily do this with TextRider!
> > Either one had to wrap the module names in quotes or
> > do ReadChar (!) or ReadIdent (doesn't work if module starts
> > with a digit!).
>
> Since when can module names start with a digit? I believe, Scanner
> will give you what you want (although it will choke on
> 2module.command).
Modules can't start with digits but files in general can.
I withdraw the proposal, and instead intend to create a new
module called Tokenizer that essentially does strtork()-like
parsing, with a user-defined set of delimiter characters.
No point messing up TextRider to support this.
Sample usage:
VAR
t : OttTokenizer.Tokenizer; buf: ARRAY 100 OF CHAR;
BEGIN
t := OttTokenizer.Connect(channel);
(* default delimiters are whitespace chars *)
t.GetToken(buf);
WHILE (t.res = t.done) DO
(* .. process buf .. *)
t.GetToken(buf);
END;
OttTokenize will also support some basic ARRAY OF CHAR
to scalar data type conversion routines, to avoid the programmer
having to include IntStr, LRealStr, etc.
n := OttTokenize.ToInt(buf, res);
myRealVar := OttTokenize.ToReal(buf, res);
etc.
--Ian