New Alpha_(re)

Wed, 23 Apr 1997 12:11:36 -0700 (PDT)


>> CONST n:1..16=6; {"subrange bounds are not of the same type"}
>...
>This is a known shift/reduce conflict in the parser.  In principle it
>should be possible to tell bison to shift it rather than to reduce it -

Actually, bison (and yacc) automatically do a shift for a shift/reduce
conflict.  That is why the error.  It shifts the = on the parse stack
to get a handle of E=E and that is considered the upper bound.  What
you want here is to force the reduce, so the 16 is reduced to an expression
and the = remains as part of the "const x = value;"  By forcing the reduce
then the construct "CONST  N : false .. 1 = 1 = false;" produces a syntax
error.  But, you can still do this by "CONST  N : false .. (1 = 1) = false;";
So I would say that you do want to force the reduce and make equals have to be
parenthesized to get comparison.

To get it, you need a fake precedence and use the "%prec" construct on the 
proper rule in the grammar.  If you can't figure it out, I'll get a copy of
the alpha and try to get a patch to you.

-- 
Phil Nelson                       NetBSD: http://www.netbsd.org
e-mail: phil@cs.wwu.edu           LPF: http://www.lpf.org
http://www.cs.wwu.edu/~phil       !gifs: http://www.lpf.org/Patent/Gif/Gif.html


Phil Nelson (phil@cs.wwu.edu)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es