Grokbase
x

Re: 5.8.0, possible parsing bug? ([perl #20727] too)

View PostFlat  Thread  Threaded | < Prev - Next >
Enache Adrian Re: 5.8.0, possible parsing bug? ([perl #20727] too)
| +1 vote
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Thu, Mar 13, 2003 at 12:54:38PM +0100, Rafael Garcia-Suarez wrote:
> Fergal Daly <fergal@esatclear.ie> wrote:
> > Yes, Perl's syntax error stuff sucks, it's often completely wrong about the
> > line number, especially when a big if/else is involved. I suspect it's a big
> > job to fix that although, I have no idea how to go about it,
>
> Use another parser generator than yacc ?

if if .. else line-numbers problem isn't the parser's fault anyway.
Perl will print the correct line number in something like

if ($p) {
;
} elsif ( hi!  I'm a syntax error) {
;
}

but not in

if ($p) {
;
} elsif ( die "dying" ) {
;
}

That's because Perl keeps the line numbers only in STATEOP's.
I see no other solution than bloating the produced code with
nextstates - just for that.
That would be really stupid.
And even if every elsif ( .. ) will become elsif ( { .. } )
some people will say it still sucks and give examples:

1,
2,
3,
warn "add three lines ";

Regards
Adi

Thread : 5.8.0, possible parsing bug?
1)
Joshua Hoblitt This seems to only pop up when doing a one liner. Is this a bug in the parser or a feature? I...
2)
Kay Roepke Feature. Definitely. :-) I don't. You can always write "( )" instead. perl -ew '1?:1' is *not* the...
3)
Joshua Hoblitt My bad. That still doesn't explain......
4)
Fergal Daly 1?:1 is incorrect Perl. perl -e '1?:1' will also give a syntax error. The problem was previously...
5)
Joshua Hoblitt That is a very good answer to my question. So now on to question #2: Why isn't '1?:1' valid Perl?...
6)
Kay Roepke The ?: operator is ternary, i.e. requires three arguments. The first, in front of the '?' is the...
7)
Fergal Daly isn't '1?:1' valid Perl? Explicitly saying undef or 0 or whatever is not that much work and doesn't...
8)
Joshua Hoblitt Ok, lets drop this off list after this post. undef and a null list are not equivalent. What I'm...
9)
Ronald J Kimball If you want to return an empty list, then specify an empty list: Your example *is* a syntax error;...
10)
Fergal Daly think a null list should be the default value returned if nothing is defined. As more often then...
11)
Rafael Garcia-Suarez Use another parser generator than yacc ?
12)
Aaron Sherman Woohoo! Now you're talking. I'll whip out the Parse::RecDescent manpage and have you a Perl grammar...
13)
Rafael Garcia-Suarez It's fine for perl to rely on bison extensions, perl sources are distributed with an...
14)
Fergal Daly the big Oops didn't mean to post that to the list, not for fear of offending but for fear of anyone...
15)
Enache Adrian if if .. else line-numbers problem isn't the parser's fault anyway. Perl will print the correct...
16)
Fergal Daly The problem is that perl -ew is not the same as perl -we. When it's after the -e, the w is taken as...
paperclip
spacer
View PostFlat  Thread  Threaded | < Prev - Next >