On Mon, 7 Jul 2003, T.M. Sommers wrote:
> These are not problems with lex and yacc specifically; any program
> parsing abc will have to face them. They are ambiguities, or potential
> ambiguities, in the language itself.
>
> In the first case above, there should be no problem: the composer field
> is only in the header and starts a line, and the staff labels are in the
> V field also in the header.
Contrary to what one would expect, this is more
problematic to deal with in Lex/Yacc than in other
parsers. The point is that Lex/Yacc do not have
facilities for context dependent tokenizing (are we in
a header or outside) nor a clean interface to exchange
information between the scanner and the parser. So one
would have to resort to global flags, which would make
the parser among other things thread-unsafe.
> In the second case (which is really a lexing issue), either disallow two
> single bars next to each other (does such a construct even make sense?),
> or require whitespace between them.
Well,
bar: '|' { $$.type = T_REG_BAR }
| '|' '|' { $$.type = T_DBL_BAR_1 }
;
Is all it takes to create a shift/reduce conflict in
Yacc.
> or perhaps better, do not allow a-g and A-G as body fields.
Alas, they are in the standard.
Groeten,
Irwin Oppenheim
[EMAIL PROTECTED]
~~~*
Chazzanut Online:
http://www.joods.nl/~chazzanut/
To subscribe/unsubscribe, point your browser to: http://www.tullochgorm.com/lists.html