TP lex change input buffer

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

TP lex change input buffer

Darius Blaszyk
Hi,

I'm using TP lex in my application and I would like to change the input buffer from using files to (memory) strings. What is the supposed way to do this? Currently I have made a local copy of lexlib and modified the get_char (and friends) routine. However this does not seem to be the ideal way to do it, although the comments in lexlib seem to indicate otherwise.

Regards, Darius

 

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TP lex change input buffer

leledumbo
Administrator
> I'm using TP lex in my application and I would like to change the input buffer from using files to (memory) strings. What is the supposed way to do this?

From the comments:
"The variables yyinput and yyoutput are the text files which are used
by the lexical analyzer. By default, they are assigned to standard
input and output, but you may change these assignments to fit your
target application (use the Turbo Pascal standard routines assign,
reset, and rewrite for this purpose)."

Thankfully, we also have:
http://www.freepascal.org/docs-html/3.0.0/fcl/streamio/index.html

Which can turn any TStream descendant into a TextFile. Just change Assign as in the comment above into AssignStream, everything else is totally the same.