Joel Reymont wrote:
> And here's a more concise version.
>
> It's 11:17pm on my end and I've been working on this all day so I'm
> probably missing something obvious :-(.
>
> (yacc:define-parser parser
> (:start-symbol sections)
> (:terminals (|;| :id1 :id2))
>
> (sections (sections section) section)
>
> (section statements)
>
> (statements (statements statement)
> statement)
>
> (statement ()
> (open-statement |;|)
> (closed-statement |;|))
>
> (open-statement :id1)
> (closed-statement :id2)
>
> )
I think you want <statements> to include <empty>, not <statement>.
Plus, I think if you equate <section> with <statements> then you
might as well get rid of <sections> altogether and make <statements>
your start symbol. I think what you really want to do is define
<section> as (<statements> <section-delimiter>) or something to
break it up. I'm not positive, though. I can never remember how
to set up yacc, either. I always have to mess with it for awhile.
Matt