.y & precedence

Sven Panne Sven.Panne@informatik.uni-muenchen.de
Sun, 28 Jan 2001 18:43:51 +0100


Hans Aberg wrote:
> [...] Does Hugs handle that [ i.e. infix & friends ] internally
> (externally to the .y grammar)?

That's correct, IIRC. It uses the standard technique here:

   * Remember fixity/precedence declarations in a table, but ignore them
     during pattern/expression parsing

   * A simple operator precedence parser rearranges the expression/pattern
     part of the parse tree afterwards, using the collected table

This is only from the top of my head, so I may be wrong, but given the
inflexibility of yacc & friends in this respect, I doubt there is a
fundamentally different way of doing this.

Note that "expanding out" the grammar w.r.t. fixity/precedence would
lead to a *huge* parser, and is no help at all when there are
infinitely many precedence levels, like in Prolog (IIRC).

Cheers,
   Sven