Re: x + (y) + z

2005-03-07 Thread Frank Heckenbach
Derek M Jones wrote:

> Unfortunately glr parsing is not a universal solution.  It requires that
> at the end of processing there be a unique parse tree (the multiple
> parse trees that may exist while processing the input tokens are required
> to eventually resolve to a single parse).

Have you looked at `%merge'?

Frank

-- 
Frank Heckenbach, [EMAIL PROTECTED]
http://fjf.gnu.de/
GnuPG and PGP keys: http://fjf.gnu.de/plan (7977168E)


___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison


Re: x + (y) + z

2005-03-07 Thread Derek M Jones
Frank,

>> Unfortunately glr parsing is not a universal solution.  It requires that
>> at the end of processing there be a unique parse tree (the multiple
>> parse trees that may exist while processing the input tokens are required
>> to eventually resolve to a single parse).
>
>Have you looked at `%merge'?

That option has the limits on its use as %dprec.


derek

--
Derek M Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards Conformance Testing   http://www.knosof.co.uk




___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison


Re: x + (y) + z

2005-03-07 Thread Frank Heckenbach
Derek M Jones wrote:

> Frank,
> 
> >> Unfortunately glr parsing is not a universal solution.  It requires that
> >> at the end of processing there be a unique parse tree (the multiple
> >> parse trees that may exist while processing the input tokens are required
> >> to eventually resolve to a single parse).
> >
> >Have you looked at `%merge'?
> 
> That option has the limits on its use as %dprec.

Which limits exactly? I tried it with your original example
`x + (y) + z' and it seems to work well (see attachment).

If your grammar is different and it doesn't work for you, it might
help to post the relevant parts of your actual grammar.

Frank

-- 
Frank Heckenbach, [EMAIL PROTECTED]
http://fjf.gnu.de/
GnuPG and PGP keys: http://fjf.gnu.de/plan (7977168E)


ambiguity.y
Description: Binary data
___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

$B$O$8$a$^$7$F!y(B

2005-03-07 Thread $B$f$+$j(B
$B$O$8$a$^$7$F!#$f$+$j$C$F$^$9!#(B
$B%;%C%/%9%U%l%s%I$rJg=8$7$F$^$7$?$h$M!)(B
$B$o$?$7!"1~Jg$7$F$b$G$7$g$&$+!)(B
$B$(!<$H!"H`;a$O$$$k$s$G$9$,!"K~B-$7$F$J$/$F!"(B
$B$<$R!"%(%C%AM'C#$K$J$C$F$[$7$$$G$9!#(B
$B=;$s$G$k=j!"6a$$$_$?$$$J$N$G!"(B
$B$^$:$O%([EMAIL PROTECTED](B
$B%+%s%?%s$J%W%m%U$r=q$-$^$9$M!#(B
$B$5$,$i$f$+$j!JK\L>$G$9!#4A;[EMAIL PROTECTED])!!>P!K!"(B
$B#2#4:P$G!"?&6H$O%F%l%[%s%*%Z%l!<%?!<$G$9!#(B
$B%9%j!<%5%$%:$O>e$+$i#9#2!#1!#8$G!"6;$O#G%+%C%W$G$9!#(B
$B$A$g$C$H%"%k%S%N$C$]$$46$8$J$N$G!"(B
$BF|>F$1$7$?%.%c%k7O$,[EMAIL PROTECTED]"[EMAIL PROTECTED](B
$B$(!<$H!"@-JJ$H$7$F!"
(B
(B
(B
(B___
(BHelp-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Re: x + (y) + z

2005-03-07 Thread Derek M Jones
Frank,

>> >Have you looked at `%merge'?
>> 
>> That option has the limits on its use as %dprec.
>
>Which limits exactly? I tried it with your original example
>`x + (y) + z' and it seems to work well (see attachment).

%dprec also works fine with the this, original, example.

The problem comes with '(x) + (y) + z' (which I gave as
a example on comment in this thread, rather than starting a
new thread; as if people were not confused enough).
There are four possible parses of this expression: two
of which are causing my current problem.  The two
possible parse trees of interest are

  +
/\
   (cast)   z
   /   \
  x +
 |
()
 |
 y

and

 +
   /\
 ()(cast)
  |  / \
  x y  +
 |
 z
>If your grammar is different and it doesn't work for you, it might
>help to post the relevant parts of your actual grammar.

Your grammar contained a single %merge.  I thought at
least two are required?


derek

--
Derek M Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:[EMAIL PROTECTED]
Applications Standards Conformance Testing   http://www.knosof.co.uk




___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison


Re: x + (y) + z

2005-03-07 Thread Frank Heckenbach
Derek M Jones wrote:

> The problem comes with '(x) + (y) + z' (which I gave as
> a example on comment in this thread, rather than starting a
> new thread; as if people were not confused enough).
> There are four possible parses of this expression: two
> of which are causing my current problem.  The two
> possible parse trees of interest are
>
> >If your grammar is different and it doesn't work for you, it might
> >help to post the relevant parts of your actual grammar.
> 
> Your grammar contained a single %merge.  I thought at
> least two are required?

All the involved (top-level) rules must have a `%merge'. In the
original example, both happened to be the same rule.

The second example works and shows all four trees (after fixing a
few precedences in the grammar) with another `%merge' -- in the
final grammar you might need some more.

Frank

-- 
Frank Heckenbach, [EMAIL PROTECTED]
http://fjf.gnu.de/
GnuPG and PGP keys: http://fjf.gnu.de/plan (7977168E)


ambiguity.y
Description: Binary data
___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Re: x + (y) + z

2005-03-07 Thread Hans Aberg
At 18:12 + 2005/03/06, Derek M Jones wrote:
>Unfortunately glr parsing is not a universal solution.  It requires that
>at the end of processing there be a unique parse tree (the multiple
>parse trees that may exist while processing the input tokens are required
>to eventually resolve to a single parse).

You can try using %merge, and then in the merge action function build in the
split-parse info. (For example, registering the different parses.)

  Hans Aberg




___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison


Re: x + (y) + z

2005-03-07 Thread Hans Aberg
At 02:14 + 2005/03/07, Derek M Jones wrote:
>>Paul Hilfinger is thinking about actions that during a split are executed
>>immediately, in addition to those delayed until the merge. This will enable
>>the kinds of things that you are asking for, I think, as one then can build
>>the parse trees, and make a selection based on that.
>
>I think the only way forward is for me to write some code, in yyparse,
>to select between the various parses when an ambiguity is detected.

You must merge them at some point, but you might use %merge to keep track of
the both parses using a merge-function then. (See the Bison manual, sec
1.5.2.)

  Hans Aberg




___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison


Re: x + (y) + z

2005-03-07 Thread Hans Aberg
At 16:06 + 2005/03/07, Derek M Jones wrote:
>Frank,
...
>Your grammar contained a single %merge.  I thought at
>least two are required?

I think that you should just merge together the tokens becoming
indistinguishable by your exclusion of context-information. You then get
certain reduce/reduce conflict. These can then be merged together using
%merge. If you need to keep track of the different parses somehow, encode
that in the merge function. This method, if it works, will be considerably
faster than using any more general nondeterministic parsing method that
keeps track of all the different parses without merging them.

  Hans Aberg




___
Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison