help-bison
[Top][All Lists]
Advanced

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

Re: Bison Question: Ambiguous Grammar?


From: Claus Brabrand
Subject: Re: Bison Question: Ambiguous Grammar?
Date: Fri, 6 May 2005 19:21:56 +0200

Hans Aberg wrote:

At 12:49 +0200 2005/05/06, Claus Brabrand wrote:

I have a question about Bisons GLR parser.

Is there a way for Bison (in %glr-parser mode) to return a parse tree
(doesn't matter which) when parsing according to an ambiguous grammar?

Bison never returns a parse tree. If you want that, you need to define its construction in the actions. When people ask that question, they often need much less; if you so want, you may precise your programming situation.

Hans,

Thanks for your reply.

Yes, I realize there's no parse tree beyond what I may chose to construct in the action code myself.

What I meant is: is there a way for Bison to take the actions according to one (any) of the parses?

I am using Bison in GLR-mode for code-generating syntax-directed transformations (executed in the action code). The grammars are highly ambiguous which is fine: I just want to execute actions
for one (any) of the parses.

I have a grammar which is capable of parsing a string (and returning a transformed string which is just the result of executing the corresponding action code). Now, when I add a certain production to this grammar, I get a parse error in the middle of the string it was able to parse without this extra production(?!?) What I don't understand is how adding a production to a grammar G can cause it to reject the string - it should just enlarge the language induced by the grammar - and so, that if it was capable of parsing my string before, it should also be able to do so after (with the extra production).

This really puzzles me(?)

Is Bison's GLR algorithm intended for ambiguous grammars or will it only work on the subset of grammars that are unambiguous (LALR(1) or not)? Maybe this particular production renders the grammar ambiguous (at least wrt. my input string - i.e. that my string has two parses).

I would greatly appreciate any insights you might have!

Thanks,
/Claus.
--
Claus Brabrand, Ph.D.
address@hidden
http://www.daimi.au.dk/~brabrand/




reply via email to

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