[fpc-pascal]absolute identifier

ron wilson ron.wilson at coastgames.com
Tue Mar 26 04:43:58 CET 2002


ok - i found some help on this, but its not solving my problem.

----- paste from
http://members.tripodnet.nl/electrickery/comp/tp30/tp30_22.html -----
Absolute may also be used to declare a variable "on top" of another
variable, i.e. that a variable should start at the same address as another
variable. When absolute is followed by the variable (or parameter)
identifier, the new variable will start at the address of that variable (or
parameter).

Example:

var
Str: string[32];
StrLen: Byte absolute Str;

The above declaration specifies that the variable StrLen should start at the
same address as the variable Str, and since the first byte of a string
variable gives the length of the string, StrLen will contain the length of
Str.
----- end paste -----

so in my application, yyleng is referencing the length of the string,
yytext, by using the absolute identifier.  i thought i could change all
references to yyleng to length(yytext), but the lexer often assigns yyleng
manually (ugh!), e.g. yyleng:=n; OR inc(yyleng);.

ron wilson.

-----Original Message-----
From: fpc-pascal-admin at deadlock.et.tudelft.nl
[mailto:fpc-pascal-admin at deadlock.et.tudelft.nl]On Behalf Of ron wilson
Sent: Monday, March 25, 2002 07:57 PM
To: fpc-pascal at deadlock.et.tudelft.nl
Subject: [fpc-pascal]absolute identifier


hi everyone!

i'm modifying a lexer for use in my telnet game proxy and i need to move the
following variables into a type record so that i pass it as a variable and
manage multiple telnet streams with the same lexer code.  the current code
uses globals (yuk).

    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;

the problem is that when i do this:

  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

i'm still re-learning pascal and i dont recall what the identifer ABSOLUTE
is for.  i can't seem to find any documentation on the net that can tell me
what it does.  if i remove the absolute,

      yyleng            : Byte;

it compiles fine, but gives a range check error on execution.  i think the
problem is here.  what function does the absolute identifier serve?  what
does the reference back to yytext mean?   how can i repair the code?  i'm
using turbo pascal lex/yacc, which also works with freepascal:
http://www.musikwissenschaft.uni-mainz.de/~ag/tply/tply.html
sure, a lexer may be overkill, but its making my life a lot easier!

thanks in advance,

ron wilson.


_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal






More information about the fpc-pascal mailing list