help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [REQUEST] Infinite recursion warning


From: Ron Burk
Subject: Re: [REQUEST] Infinite recursion warning
Date: Sun, 15 Dec 2013 09:11:35 -0800

In my own parser generator tinkering (where I care greatly about
explanations), I would say:
    'list' is a nonterminal that never terminates.
and link to a longer explanation of that concept.
This is probably the most succinct diagnostic,
since the problem is not what any of the 'list'
rules does, but what *none* of them do: terminate.

Is there more that could be done? Certainly I could
demonstrate why each 'list' rule does not terminate,
but in this and many other such cases, that would
add verbosity without much value, since once the
problem is named, it is easily visible. I could construct
situations where it is not obvious by glancing at a rule
to see that/why it never terminates, but I have not seen
such a situation arise in the wild. The time might be
better spent on more general exploratory mechanisms,
such as the ability to generate some sample sentences
from a non-terminal that was mentioned in an error message.

However, there definitely is more work to do here for
the tool author who cares about UX. You don't want this
error to cascade (like the awful unintelligible cascade you
get if you misspell the definition of an oft-used nonterminal
in a complex grammar). For example, 'list' might have been tacked
on to the right hand side of the rules of multiple other non-terminals,
in a way that causes *them* to be non-terminating. It's somewhat
tedious, but certainly possible, to identify the root cause
in such situations and avoid confusing the user with superfluous
complaints.


On Tue, Dec 10, 2013 at 11:34 AM, Valentin Tolmer
<address@hidden> wrote:
>> Hi Valentin,
>>
>> I suppose you mean that the message should be clearer?
>>
>> $ cat foo.yy
>> %%
>> exp: "NIL" | "NIL" list
>> list: "NIL" list
>> $ LC_ALL=C bison foo.yy
>> foo.yy: warning: 1 nonterminal useless in grammar [-Wother]
>> foo.yy: warning: 2 rules useless in grammar [-Wother]
>> foo.yy:2.20-23: warning: nonterminal useless in grammar: list [-Wother]
>>  exp: "NIL" | "NIL" list
>>                     ^^^^
>> foo.yy:2.14-23: warning: rule useless in grammar [-Wother]
>>  exp: "NIL" | "NIL" list
>>               ^^^^^^^^^^
>> foo.yy:3.7-16: warning: rule useless in grammar [-Wother]
>>  list: "NIL" list
>>        ^^^^^^^^^^
>>
> Hi Akim,
>
> Sorry I forgot to include the error message.
> Yes indeed, it could be clearer to mention an infinite recursion, or
> no words matched, or something like that.
> The current error makes you think that the rule was useless because it
> could not be reached, or that another rule always takes precedence
> over this one.
>
> --
> Valentin Tolmer
>
> _______________________________________________
> address@hidden https://lists.gnu.org/mailman/listinfo/help-bison



reply via email to

[Prev in Thread] Current Thread [Next in Thread]