[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 22:40:35 +1100 (EST) |
On 21 Nov 2000, Akim Demaille wrote:
> >>>>> "Matthew" == Matthew Palmer <address@hidden> writes:
>
> Matthew> That, and that only. "2 useless nonterminals and 3 unused
> Matthew> rules". The parse.output listed which rules and nonterminals
> Matthew> it was, but nothing more.
>
> Well, that's more :)
It didn't help me materially with debugging the grammar, but that was my
inexperience with grammars.
> >> Your snippet has several flaws, but most probably due to the fact
> >> that you cut some other relevant parts. In particular I can't see
> >> any useless nonterminal here.
>
> Matthew> I thought I'd provided the flow of control, perhaps not.
>
> You may have the starting point of http_proxy_list elsewhere, I don't
> know. And host was not defined.
http_proxy_list was startd from start, which also has a pile of other rules
to deal with other code.
> Matthew> What fixed it, AFAICT, was placing a required colon and port
> Matthew> number after the hostname, as in
>
> Matthew> http_proxy: host COLON_TOK PORTNUM_TOK
>
> But then you change the language! Unless you add a rule
>
> http_proxy: host
>
> you now allow host only when followed by COLON_TOK PORTNUM_TOK.
Well, since I'm defining the language as I go along... <g>
It turns out that making the portnum required is a better option anyway,
since defaulting out on ports in this circumstance is a Bad Thing...
> Matthew> Although at some stage I think I added the single-element
> Matthew> list thingy in there, too, which may have fixed it.
> Matthew> Basically I was just moving things around trying to fix it,
> Matthew> and stumblerd across the solution. I don't know what exactly
> Matthew> fixed it, because I didn't keep perfect records of everything
> Matthew> I did, but it now produces a valid parser, with no errors,
> Matthew> and which produces the required behaviour.
>
> Don't trust a grammar when you don't understand why it's fixed.
I understand why my original one wasn't working - several reasons. I just
tried fiddling with the grammar and I know why I specified COLON_TOK
PORTNUM_TOK - because otherwise it clashes with a r/r conflict with another
rule (which is identical in RHS to http_proxy). Better this way, anyway.
> Basically the grammar you sent was:
[my abbreviated grammar snipped for brevity]
I think I snipped a little too much, but I thought at the time I had all the
important stuff. The whole thing was awfully large, though, I thought, and
didn't want to annoy anyone. Next time, more context. (Next time, no
beeginner's mistakes).
--
-----------------------------------------------------------------------
#include <disclaimer.h>
Matthew Palmer
address@hidden
Re: Useless nonterminals - what and why?, Akim Demaille, 2000/11/21