help-bison
[Top][All Lists]
Advanced

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

Re: Useless nonterminals - what and why?


From: Akim Demaille
Subject: Re: Useless nonterminals - what and why?
Date: 21 Nov 2000 10:40:05 +0100
User-agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands)

>>>>> "Hans" == Hans Aberg <address@hidden> writes:

Hans> It looks wrong to me -- perhaps Bison substitutes an empty
Hans> relation, making your code work or something.

Fortunately not, the semicolon is optional:

reader.c:
          if (t == SEMICOLON)
            t = lex ();


Hans> Akim: Is this a Bison bug (handling of excluded ";") or
Hans> something?

Bison leaves a lot of freedom wrt separators.  You can even

%token tok1, tok2, tok3

etc.

BTW, I just discovered a feature I was unaware of, which is related to
the diagnostic you gave on this grammar:


/tmp % cat list.y
%token element
%nterm list
%%
list : list element {}
/tmp % LC_ALL=C bis list.y
list.y contains 1 useless nonterminal and 1 useless rule
list.y:5: fatal error: Start symbol list does not derive any sentence


/tmp % cat list.y
%token element
%nterm list
%%
list : list element {} | element {}
/tmp % LC_ALL=C bis list.y
/tmp %



reply via email to

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