Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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)


Comment on Re: Help with tweaking Parse::RecDescent grammar
Select or Download Code
(jeffa) 2Re: Help with tweaking Parse::RecDescent grammar
by jeffa (Chancellor) 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. ;)

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
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.

    Abigail

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2014-07-24 04:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (157 votes), past polls