develooper Front page | perl.perl5.porters | Postings from March 2014

Re: [perl #121501] Empty code block {} causes syntax error (misparsedas anonymous hash constructor?) before 'sub'

Thread Previous | Thread Next
From:
Eric Brine
Date:
March 25, 2014 16:52
Subject:
Re: [perl #121501] Empty code block {} causes syntax error (misparsedas anonymous hash constructor?) before 'sub'
Message ID:
CALJW-qHZUM2qU0YCAOaBz=ge8gq+wM+kaGqC0YGqvWRZKBg40w@mail.gmail.com
On Tue, Mar 25, 2014 at 11:34 AM, Ed Avis <eda@waniasset.com> wrote:

> I did not forget that {} is also the anonymous hash constructor - see the
> subject of this bug report.
>
> What I suggest, if it is possible, is that where {} is currently parsed as
> a hash constructor but that
> gives a syntax error, perl should try instead to parse it as a block.


LL parsers love to parse the same text over and over again (though you can
prevent this if careful), but Perl uses an LR parser and resolves these
conflicts by looking ahead.

"{" is determined to be a hash constructor by looking ahead and seeing "}".
It would have to look even ahead further to determine a syntax error
follows that. I don't know how feasible that is.

Thread Previous | Thread Next


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