Thomas Järvstrand writes:First off, even if you get a shift/reduce conflict for this, the default
> In erlang a macro is written as ?atom or ?atom([arguments])
> In my grammar this translates to the rule:
> : WHY ATOM PAREN_BLOCK
> | WHY ATOM
is to do shift in such a case, so it should still work. Of course, if
the problem is fixable in the grammar, it should be fixed.
No, %precedence does not exist. However, I think using %nonassoc has
> I've tried solving this by changing this to (using %nonassoc because I couldn't
> find any evidence of the %precedence declaration existing in semantic):
> %nonassoc PARAMETERIZED-MACRO
> %nonassoc MACRO
pretty much the same effect. As far as I can see, the difference in
Bison is whether using the operator in an associative way is a run-time
or compile-time error. That being said, I don't think you need to fiddle
with precedence here.
I'd really need to see the full grammar to see the problem (the conflict
> : WHY ATOM PAREN_BLOCK %prec PARAMETERIZED-MACRO
> | WHY ATOM %prec MACRO
> But I still get a warning for a shift/reduce conflict when compiling the
> grammar. What is the correct way of solving this issue?
might be due to interaction of separate rules), but this problem is
usually dealt with by using an additional rule for an optional argument
which contains an empty match, like
: WHY ATOM optional-args
: ;; EMPTY
(EXPAND $1 argument-list)
: ... deal with open/close-paren and list of arguments ...
You should find many examples like this in other grammars, like in c.by
the optional initialization of variables:
| ;; EMPTY
or in java.wy you'll find lots of non-terminals ending in '_opt'.