Related articles |
---|
[3 earlier articles] |
Re: How detect cycle in grammar ? anton@mips.complang.tuwien.ac.at (2011-11-22) |
Re: How detect cycle in grammar ? a.moderacja@gmail.com (Borneq) (2011-11-23) |
Re: How detect cycle in grammar ? a.moderacja@gmail.com (Borneq) (2011-11-24) |
Re: How detect cycle in grammar ? quinn_jackson2004@yahoo.ca (Quinn Tyler Jackson) (2011-11-25) |
Re: How detect cycle in grammar ? gene.ressler@gmail.com (Gene) (2011-11-27) |
Re: How detect cycle in grammar ? gene.ressler@gmail.com (Gene) (2011-11-27) |
Re: How detect cycle in grammar ? anton@mips.complang.tuwien.ac.at (2011-11-28) |
Re: How detect cycle in grammar ? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2011-11-29) |
Re: How detect cycle in grammar ? paul@paulbmann.com (Paul B Mann) (2011-12-01) |
Re: How detect cycle in grammar ? quinn_jackson2004@yahoo.ca (Quinn Tyler Jackson) (2011-12-02) |
Re: How detect cycle in grammar ? gene.ressler@gmail.com (Gene) (2011-12-07) |
From: | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
Newsgroups: | comp.compilers |
Date: | Mon, 28 Nov 2011 16:46:51 GMT |
Organization: | Institut fuer Computersprachen, Technische Universitaet Wien |
References: | 11-11-041 11-11-045 11-11-050 11-11-057 |
Keywords: | parse, theory |
Posted-Date: | 29 Nov 2011 01:53:42 EST |
Gene <gene.ressler@gmail.com> writes:
>It's also worth noting that any grammar with A->A in it is ambiguous
>in a way that should cause LR table generation to fail. How would a
>parser know how many times to reduce A->A?
S -> A|B
A -> A
B -> t
This grammar can derive only the word "t", and only in one way. I see
no ambiguity; no word can be derived in two ways in this grammar.
As for warning about these useless cycles, sure, they may indicate a
programming mistake, so better warn about them. I still don't see
that they are a problem as far as their meaning is concerned, nor
wrt. implementability in general. Apparently the Bison implementors
thought so, too, or Bison would produce an error, not a warning.
- anton
--
M. Anton Ertl
anton@mips.complang.tuwien.ac.at
http://www.complang.tuwien.ac.at/anton/
Return to the
comp.compilers page.
Search the
comp.compilers archives again.