develooper Front page | perl.recdescent | Postings from September 2004

offsetlinenum

From:
Alexander.Farber
Date:
September 19, 2004 07:01
Subject:
offsetlinenum
Message ID:
20040919140135.GK25426@pref.my.domain
Hi,

in the Parse/RecDescent.pm, what is the offsetlinenum used for?

I'm trying to understand, what does this in the P::RD::LineCounter mean:

sub STORE
{
        my $parser = $_[0]->{parser};
        $parser->{offsetlinenum} -= $parser->{lastlinenum} - $_[1];
        return undef;
}

When a $thisline = 10 is called, why doesn't the STORE do 
something simple, like $parser->{MyCurrentLine} = $_[1] ?

Is offsetlinenum somehow used to cache the current line number,
so that _linecount($text) is not called too often?

Regards
Alex

PS: In the AUTOLOAD() isn't the first line below redundant?

       $_[0]->{lastlinenum} = $_[2]||_linecount($_[1]);
       $_[0]->{lastlinenum} = _linecount($_[1]);




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About