[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Useless nonterminals - what and why?
From: |
Matthew Palmer |
Subject: |
Re: Useless nonterminals - what and why? |
Date: |
Tue, 21 Nov 2000 21:10:18 +1100 (EST) |
On Tue, 21 Nov 2000, Hans Aberg wrote:
> At 09.57 +1100 0-11-21, Matthew Palmer wrote:
> >> Think of the rule as written (as when debugging is turned on)
> >> http_proxy_list <- http_proxy_list http_proxy
> ...
> >> there is not any other rule for finding a http_proxy_list, so you can
> >> never find the RHS http_proxy_list.
> >
> >Aha, is that how it works? Funny, the bison manual never mentioned anything
> >of that sort, and it recommended using this sort of recursion to prevent
> >huge stack blowouts.
>
> Which quote in the Bison manual do you have in your mind?
Section 3.4 on Recursive Rules, where it states "you should always use left
recursion because it can parse a sequence of any number of elements with
bounded stack space". I neglected to study the examples properly, where
they define a list as being " element | list element". Oops.
> -- There is not anything wrong with the relation itself, but it needs an
> additional startup relation.
It shall be done in future.
> >> Note that you forgot terminate the rules with ";" in the original post.
> >> Have you done it now?
> >
> >I'm not sure (haven't got the code with me ATM), but I don't think any of
> >the rules are terminated by a semi-colon, and it works just fine. I may be
> >wrong on that, as I didn't take a huge pile of notice.
>
> It looks wrong to me -- perhaps Bison substitutes an empty relation, making
> your code work or something.
Checked the code - no semicolons. As to making the thing work, on further
inspection it would seem that I now have a simple http_proxy as an
alternative http_proxy_list. I did a lot of things to make it work, and
that must have been one of them.
Certainly I've learned my lesson now about it all, and understand grammar
definition a lot better. Thanks for your patience.
--
-----------------------------------------------------------------------
#include <disclaimer.h>
Matthew Palmer
address@hidden
Re: Useless nonterminals - what and why?, Akim Demaille, 2000/11/21