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: Frank Heckenbach
Subject: Re: Non-greedy wildcard possible? (Long)
Date: Tue, 18 May 2004 03:09:57 +0200
User-agent: semail 20040101

Laurence Finston wrote:

> I had a problem that reminds me of this.  Sometimes, one would like to
> "get out of" a rule in `yyparse()' and "get into" another rule.  I
> believe this to be impossible, except with `gotos', which is risky.
> If one does it, then one must be very careful about using the semantic
> values of the tokens of all the rules involved.  I _don't_ recommend
> it.

If you mean a `goto' from one action into another, this will
certainly not work. The actions in `{ ... }' are just for the
semantic values and irrelevant for the actual parsing.

What you achieve is at best to execute a part of another semantic
action, and at worst to mess up completely, especially if the code
after the `goto' accesses any `$n' values. But the parsing will
continue with the original state (it will not even notice the
`goto'). (You could try modifying the parser's internal structures,
but before you start this, you should really try to restructure your
grammar or use a more powerful parsing algorithm, i.e. GLR.)

(This is quite different from a recursive descent parser ... where a
`goto' into another rule will also mess up -- but for different
reasons. :-)

Frank

-- 
Frank Heckenbach, address@hidden
http://fjf.gnu.de/
GnuPG and PGP keys: http://fjf.gnu.de/plan (7977168E)




reply via email to

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