Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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]
[Discipulus]: Tanktalus we will be glad to have you here more frequently, tho ;=)
[marioroy]: Lady_Aleena oh I thought you found the error by adding -exec mp3info
[Tanktalus]: Discipulus: I should be working on an interview test right now. Well, I kind of am, but keep getting myself distracted :)
[Lady_Aleena]: marioroy, nope, that IS the error.
[Discipulus]: oh to be distracted PM is still a wonderfull place
[Tanktalus]: Problem is, it's a test for another monk - as in, another monk letting me interview for his company :)
[Tanktalus]: He might see me here... :D
[Discipulus]: it's me? ;=)
[marioroy]: Lady_Aleena could it be a quoting issue? I just tried find with -exec on the command line. find . -name "*.pl" -exec ls -l {} \;
[Tanktalus]: No, I know who he is, nice try. But if you're hiring, let me know :)

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2017-04-23 19:57 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (432 votes). Check out past polls.