On Sunday 27 February 2011 09:00:03 slug-requ...@slug.org.au wrote:
> > Sections :
> >         | Section Sections
> >         | Lines
> 
> The problem is two-fold.  First, it is the convention to write iteration
> left recursively, as in
> 
> Sections
>     : /* empty */
>     | Sections Section
>     ;
> 
> This results in less depth in the parse stack, and in some cases (where
> rules are attached) results in a more-expected side-effect order (L2R
> rather than R2L).
> 
> The second problem is that both Lines and Sections can be empty.
> This make the initial parse state ambiguous.  Should it immediately
> reduce by the "Sections: /* empty */" rule, or by the "Lines: /* empty
> */" rule?
> 
> Try this instead
> 
>         Sections
>             : Lines
>             | Sections section
>             ;
> 
> Now there is no empty Sections rule, and all ambiguity goes away... the
> file always starts with a (possibly empty) non-section set of lines.
> 
> When it doubt, always read the y.output file, it will document how and
> where ambiguities occur in your grammar.

Peter thank you. In a moment you have solved many days of muddling.
I *do* read y.output but I'm not clever enough to turn the reported conflict 
into a solution <blush>
James
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to