help-bison
[Top][All Lists]
Advanced

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

Re: Non-greedy wildcard possible? (Long)


From: Hans Aberg
Subject: Re: Non-greedy wildcard possible? (Long)
Date: Thu, 3 Jun 2004 19:39:49 +0200

At 01:26 +0200 2004/06/03, Frank Heckenbach wrote:
>> This is though an important point: That no parser actions are performed
>> during the split, and in particular that the lexer cannot be fed back from
>> the parser, then. This is then also true about non-ambiguous parsing.
>
>Yes, as long as the parser is split. As I said, to the "outside
>world" it appears as if the parser uses more lookahead.

I think a similar is happening when using attribute grammars and LR parsing
together: If one assumes that the grammar variables can have inherited
attributes attached to them, then the LR actions, which are essentially
synthesized attributes, cannot be executed before the grammar variable of
the inherited attribute has been constructed.

Inherited attributes could be used to create environments: Then the meaning
(or value) of an identifier can only be resolved first when one has
determined which environment it belongs to. Perhaps LL parsing is better
for this (rather limited form of attribute grammars).

>> The C++ example is important, because it shows how GLR can be used to
>> resolve run-time parsing ambiguities.
>
>Sure. I just meant there should perhaps be an example without dprec
>as a first step. -- Yes, I know, when I say this, I should rather
>write and post such an example. I think I could write a short
>example based on Pascal syntax, if wanted ...

The Bison manual should probably have more info on GLR -- if somebody is
willing to write it.

>> I merely want folks to investigate the standard methods with tweaks in full
>> first, and most of all, not hoping that any more advanced parsing method
>> should save them from doing the grammar writing job themselves. We have had
>> cases in this list in the past where the problem was in reality due to
>> sloppy grammar analysis; then GLR won't save you.
>
>Of course. OTOH, when we're talking about lexer tricks vs. GLR
>parsing, I'm not sure which one is generally preferable. (FTR, I'm
>using both, in different cases.)

The implicit working assumption in the comments that I made, and which you
parsed as GLR-negativism, was that the grammar problem of the fellows
asking might not have been properly settled. And, in fact, it proved to be
so in some of the queries. So when somebody is asking questions, one has to
include that possibility, as well.

Otherwise, I am thinking of versions where the lexer can provide several
lexing alternatives, and then let the Bison GLR parser sort it out. This
seems useful in human languages (including say common human usage of math).
In such cases, lexer tweaking becomes very difficult, or impossible, so a
GLR approach would probably be to be preferred.

  Hans Aberg






reply via email to

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