[fpc-pascal] Customizing tply

Michalis Kamburelis michalis at camelot.homedns.org
Fri Dec 10 00:17:44 CET 2004


I'm attaching my unit TextReader, it

- implements TTextReader class (that is able to read from any TStream 
class using simple Readln and Eof methods) and

- initializes/finalizes some variables to treat standard input/output 
like a TStream classes (or, only in case of standard input, like a 
TTextReader class).

Works on Win32, Linux, FreeBSD (should work on any UNIX). I'm also 
attaching some simple demo program.

This code is part of my GNU GPLed KambiClassUtils unit on my WWW pages, 
I just extracted it for you to send something small.


Agustin Barto wrote:
> After some work I was able to translate my parser's grammar from
> Coco/R to Lex/Yacc. It wasn't easy and I hate to loose the more
> "functional" aspects of Coco/R, but at least my project can compile
> both on Windows (with Delphi) and Linux (with fpc) (at least the
> non-UI parts).
> When I started to modify lexlib to work with streams instead of just
> files (I have to parse stuff that could be on memory) I dicovered some
> new issues:
> * How can I use standard input/ouput with streams?
> * Is there an easy way to do a ReadLn (or similar) with streams? The
> idea is instead of rewriting the lexlib io functions, I replace the
> standard io functions like Eof, ReadLn, Write and WriteLn. My initial
> idea was to read the whole stream on a TStrings, but that could waste
> a lot of memory.
> Thanks in advance,
> Agustin
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: demo_textreader.dpr
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20041210/65fd5dbd/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: textreader.pas
Type: text/x-pascal
Size: 5702 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20041210/65fd5dbd/attachment.pas>

More information about the fpc-pascal mailing list