Re: shift-reduce conflict in verilog-2000 grammar

From: James A. Markevitch (jam@magic.com)
Date: Thu Nov 02 2000 - 09:12:32 PST


> However, the new grammar saddly introduces a reduce/reduce conflict,
> which makes the grammr non LALR(1) in practice, and hence impossible
> to parse with yacc. [James might share with us his magic solution...]

I don't get a reduce/reduce error related to the ANSI-style declaration
syntax, but do get them related to other constructs. For the ANSI-style
declaration, I get a shift/reduce error which is not benign (i.e. the way
if-if-else is).

I don't recall the exact construct which requires the infinite lookahead,
and need to run to a meeting, so I can't look it up. But, the "magic
solution" to this is seriously seriously ugly; if I recall, it involves
communication between the lexer and parser and an infinitely deep stack,
but I am not positive.

As to the ANSI-style construct, the grammar can be made parsable by yacc.
I haven't tried the following BNF, but it should work:

port_list ::= type_info identifier
                    port_list , port_remainder

port_remainder ::= type_info identifier { dimension }
                    identifier { dimension }

type_info ::= input [ range ]
                    output [ range ]
                    etc.

The key is that it rearranges things so that the comma only appears in
the topmost rule.

James Markevitch



This archive was generated by hypermail 2.1.4 : Mon Jul 08 2002 - 12:54:14 PDT and
sponsored by Boyd Technology, Inc.