Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2016-04

TP lex change input buffer

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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

Reply by email

leledumbo
to Darius Blaszyk
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.

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/TP-lex-change-input-buffer-tp5724893p5724895.html Sent from the Free Pascal - General mailing list .

Reply by email