"Ron D. Smith" wrote:

> Wow.  If that was "pared down" I would hate to see "the whole script" :-)

if you think what you've seen is fugly, that was the cute step-sister!


> This one is kind of subtle, and reminds me of the quote "nothing can parse
> perl except perl".
>
> The problem is in Text::Balanced::_match_quotelike where it thinks the '<<'
[...]
> looking for a BLANK LINE.

ah.

> Here is a much simpler test case which fails.
[...]
> Now PAY ATTENTION:  The only difference between the two cases is the *BLANK*
> line after the expression with the '<<' in it!!!!
> 
> Yet this works and correctly picks up the action:
> 
>     Parse::RecDescent: Treating "acu_config_cmd :" as a rule declaration
>     Parse::RecDescent: Treating ";" as a literal terminal
>     Parse::RecDescent: Treating "{ $main::Instruction_lower = 0x000000 |
>                        (($item[16] & 0x000003)<<10) ; 1; }" as an action
> printing code (4229) to RD_TRACE
> 
> The reason for the bug is that it consumes the entire input and the parser
> fails in a bizarre way that makes it think everything after the '<<' is part
> of that hereis literal.
> 
> So to fake it out, give it what it wants, which is a blank line after every
> usage of the '<<' shift operator, but you have to do it INSIDE the action.
> The original code had the blank line after the action and the parser parser
> looses it mind.
> 
> So with your original code, change it to this:
> 
> acu_config_cmd :
[...]
>                                         | (($item[16] & 0x000003) << 10)
>                                         | (($item[22] & 0xC00000) / 1024)
>                                         | (($item[22] & 0x000003) * 16384)
>                                         | ($item[26] & 0xFF0000)
>                                         ;# the next blank line is required.
> 
>                                 1;
>                         }

got it.

> 
> Yep, its just PFM.

i presume m for magic; is p for plain, pure, or perl? :-)
(i can see it now, your answer will be (wait for it!) "yes.")

i'll add the blank lines (thank you!) and then see if multiple shifts
   in the exe block will cause the parser parser to lose its mind mind.

many thanks for helping out and furthering my education.

hwn

Reply via email to