Re: Data table text I/O package?



On Thu, 16 Jun 2005 16:46:39 +0200, Georg Bauhaus wrote:

> Dmitry A. Kazakov wrote:
>
>> There is a better technique to parse strings than to tokenize them first.
>> Get rid of scanner. Just take the date from the current position of the
>> string and advance the position to the first character following the date.
>> Because the procedure that gets the date knows the format it also knows
>> where the date ends. It can also support various concurrent formats,
>> provided that they are distinguishable. This way you can parse a string
>> virtually knowing nothing about the formats of its fields. An additional
>> advantage is that error messages (if it comes to a more advanced system)
>> will be pretty easy to generate.
>
> IIUC, what you describe is a (more binary) DTD, either language-standardised
> or proprietary.
>
> And also, what does the sentence "don't scan a string, and don't
> produce tokens, but advance [something] to the first character
> following the date that was taken[?] form the string" mean,
> other than a contradiction in terms?

Field_1 : Float;
Field_2 : Integer;
...
Line : String := ...; -- The current line
Pointer : Integer; -- The current position in Line

Pointer := Line'First;
Get (Line, Pointer, Delimiters); -- Skip blanks
Get (Line, Pointer, Field_1); -- Get field and move Pointer
Get (Line, Pointer, Delimiters); -- Skip blanks
Get (Line, Pointer, Field_2); -- Get field and move Pointer
...
etc

Quite trivial.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.



Relevant Pages