Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: Mysterious "syntax error"

by dragonchild (Archbishop)
on Nov 30, 2004 at 18:12 UTC ( [id://411236]=note: print w/replies, xml ) Need Help??


in reply to •Re: Mysterious "syntax error"
in thread Mysterious "syntax error"

That doesn't answer the question as to why the two examples BrowserUk listed in his second <code> block work. Those should both be ambiguous, as well, at least to my mind. Would you mind taking a stab at explaining how perl figures those out?

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re^3: Mysterious "syntax error"
by BrowserUk (Patriarch) on Nov 30, 2004 at 22:48 UTC

    If you wanna take a look at the logic of the guess, take a look in toke.c and search for OP_MAPSTART. It's at line 4000 in the 5..8.5 source.

    (I think) The logic for making the guess starts at the comment /* Is this a word before a => operator? */ a few lines below and extends for 100 lines or so. The comments, (if not the code :), make interesting reading as to just how complex this is.


    Examine what is said, not who speaks.
    "But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
    "Think for yourself!" - Abigail        "Time is a poor substitute for thought"--theorbtwo         "Efficiency is intelligent laziness." -David Dunham
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

      That appears to be deciding how to interpret a bareword, not a '{'. I quickly looked but didn't find the code for guessing at the meaning of a '{', though.

      Actually, I'd like to see merlyn download the source from one of those 150 locations and show us how easy it is to find and interpret this code. (:

      - tye        

        Your right. Seems I missed a level of identation (easily done in that source). I also missed another, rather more obvious clue:

        # toke.c:3207 (5.8.5) /* This hack serves to disambiguate a pair of curlies * as being a block or an anon hash. Normally, expectation * determines that, but in cases where we're not in a * position to expect anything in particular (like inside * eval"") we have to resolve the ambiguity. This code * covers the case where the first term in the curlies is a * quoted string. Most other cases need to be explicitly * disambiguated by prepending a `+' before the opening * curly in order to force resolution as an anon hash. * * XXX should probably propagate the outer expectation * into eval"" to rely less on this hack, but that could * potentially break current behavior of eval"". * GSAR 97-07-21 */

        Examine what is said, not who speaks.
        "But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
        "Think for yourself!" - Abigail        "Time is a poor substitute for thought"--theorbtwo         "Efficiency is intelligent laziness." -David Dunham
        "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
•Re^3: Mysterious "syntax error"
by merlyn (Sage) on Nov 30, 2004 at 22:10 UTC
    Those should both be ambiguous, as well, at least to my mind
    What part of
    there's some "guessing" code to deal with the ambiguity
    did you miss reading? if you mean "what is the actual rules of the guessing?", well the Perl source code is available for download in about 150 CPAN locations, at least.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://411236]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-24 15:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found