Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Help with tweaking Parse::RecDescent grammar

by extremely (Priest)
on Feb 11, 2003 at 05:08 UTC ( #234321=note: print w/replies, xml ) Need Help??

in reply to Help with tweaking Parse::RecDescent grammar

You could disambiguate labels with a marker character. Just like in the P::RD code itself, L1: ADD RMOVE 1

Thus labels are terminated with a special character and your grammar never gets confused... label_name: /[a-z]\w*:/i

$you = new YOU;
honk() if $you->love(perl)

Replies are listed 'Best First'.
Re: Help with tweaking Parse::RecDescent grammar
by Abigail-II (Bishop) on Feb 11, 2003 at 13:48 UTC
    That doesn't solve his problem though. The problem isn't that IF matches a label, the problem is that the parser is trying to match IF to be a label. That means the parser has already rejected the line to be of the form opcode operand(s).

    Hence, the parsing of the IF statement failed. Where does it fail? Easy, var_value returns the value from a code block. It's looking up the value of rmove, but that variable wasn't set. Instead, the variable RMOVE was set.

    The problem here is that the parser is already doing the calculations, and causing the parse the language differently on the outcome of those calculations. Icky.

    Anything more complicated that a calculater should probably have separate compile and runtime phases.


(jeffa) 2Re: Help with tweaking Parse::RecDescent grammar
by jeffa (Bishop) on Feb 11, 2003 at 13:22 UTC
    Good idea, but this is for homework! ;) There is a Python course being taught this semester by one of my favorite professors. This is their second project, and my first thought upon seeing it (other than they should be learning Perl instead) was to attack the problem with P::RD. At first, PodMaster's suggestion worked, then i changed my code and i am still having a hard a time matching that darned 'IF'. Welcome back man, it's been too long. ;)


    (the triplet paradiddle with high-hat)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2020-10-29 11:16 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (270 votes). Check out past polls.