Quoting ron wilson :
Show quoted text 14 lines
type
tyyvars = record
yyinput, yyoutput : Text; (* input and output file *)
yyline : String; (* current input line *)
yylineno, yycolno : Integer; (* current input position *)
yytext : String; (* matched text (should be
considered
r/o) *)
yyleng : Byte (* length of matched text *)
absolute yytext;
end;
i get the following error:
Fatal: Syntax error, ; expected but identifier ABSOLUTE found
This relies on two things. 1: you are using Pascal strings (255 chars, first char (position 0) is length of string) and 2: that the address in memory of yytext will be constant, hence globals. This is never going to work nicely, but a call to 'length(yytext);' gives the same value.
You could write a routine to do something with this info:
procedure populateyyvarsdata(var data: tyyvars);
begin
data.yyleng := length(yytext);
end;
You could write this better as a class :
type
tyyvars = class(TPersistent)
private
fyytext : String;
public
yyinput, yyoutput : Text; (* input and output file *)
yyline : String; (* current input line *)
yylineno, yycolno : Integer; (* current input position *)
property yyleng : integer read getyyleng;
property yytext : string read getyytext;
end;
...
function getyyleng: integer;
begin
result := length(fyytext);
end;
function getyytext: string;
begin
result := fyytext;
end;
...
Because TPersistent is streamable, you should be able to pass it about as text. (ObjectBinaryToText and ObjectTextToBinary in Delphi.)
Just a thought anyways,
Matt
"Computer games don't affect kids; I mean if Pac-Man affected us as kids,
we'd all be running around in darkened rooms, munching magic pills and
listening to repetitive electronic music."
Kristian Wilson,
Nintendo, Inc, 1989
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d? s+++:+ a- C++ UL+ P L++ E---- W- N+ o+ K- w
O- M V PS PE-- Y PGP- t- 5-- X- R- tv+ b+ DI++ D+
G e++ h--- r+++ y+++
------END GEEK CODE BLOCK------