On Fri, Jun 13, 2003 at 01:33:58PM -0700, Ron D. Smith wrote:

> Try the $::RD_TRACE debug feature.  In the future, I'm sure you will find it 
> extremely helpful.  It both points out the problems with a grammar definition 
> as well as helps you understand what to do to optimize an implementation.

I turn RD_TRACE on - of course. Sometimes. Sometimes there is too much
and sometimes too few information in it, so prints in the action
blocks are the way.

However:

> This is both efficient as well as unambiguous:
> 
> Insensitive_With_Optional_Tail: phrase tail(?)
> 
> tail: '(' blah ')'

Yep. This is really the optimal solution that I've simply overseen, it
also renders the grammar more readable. So this worked for me very
well and I've got the parser running now.

But still I don't get why a

rule:   prod1
      | prod1 and something

won't work. Why always the longest prefix productions have to stand
first. I even suspect a flaw in the docs as when the parser encounters
an input string that'd match "prod1 and something" it should fail with
prod1 and try the second production. In fact it doesn't it throws the
complete rule away after failing the first production and simply
states, that input string could not be parsed.

That bothers me from a pedantic point of view.


-- 
best regards,

     Dipl.-Inf. Richard Jelinek

     - The PetaMem Group - Prague/Nuremberg - www.petamem.com -
                       -= 2325182 Mind Units =-

Reply via email to