On Wed, 2007-08-01 at 12:56 +1000, skaller wrote:
> So what programming language is this?

Ah .. the beauty of GLR parsing ..

/////////////////////////////
#import <flx.flxh>
int i = 1;
for (i=0; i<10; ++i) println i;

while(i>0){ println i; --i; };
do { ++i; println i; } until i==10;

if (i==10) println "Equal Ten";
else println "Not 10";

if (i==0) println "Equal Zero";
else println "Not Zero";


if(i==10)
  if(i==0) println "WRONG";
  else println "RIGHT";
else println "DOUBLY WRONG";


if(i==10) println "Right again!";
if(i==10) println "And again!";

if(i==10)
  if(i==0) println "WRONG";
  else println "RIGHT";
/////////////////////////////////


Note that Felix has its own 'if/then/else/endif' expression AND
it also has

        if expr do .. elif .. then .. elif .. then .. else .. done;

statement, yet the GLR parser disambiguates and finds the 
intended interpretation as C.

Unfortuntely .. the last group there is misinterpreted:
it matches the else with the outer statement! The grammar is:

  sifgoto := if lpar sexpr rpar statement  // i
  sifgoto := if lpar sexpr rpar statement else statement // ie

which in Felix parser system gives the second production precedence.
I expected that to work because the inner conflict should have
been merged first.. ouch .. hmm.. the problem is again, that this
isn't a merge problem of conflicting nonterminals .. well it is,
but the problem is that it is the top level statement recursion
that is made ambiguous.

We start with two parses, hit the first statement, and now
we have four parses. When we hit the 'else' both the inner
parses without the else option return, and the ones that
consume the else continue.

Now, the parse i (i) gives up, i (ie), ie (i) and ie (ie) keep
going. Now,  I expected the i/ie conflict in ie(i) and ie(ie)
to be resolved by a merge but this isn't the case! At the end,
ie(ie) is incomplete and will give up on the next token,
so the conflict is between i(ie) and ie(i) and the latter wins.

The point is that the 'inner' productions aren't merged because
they're already on two distinct forks that terminate at different
places .. it's the overlapping scope problem again.



-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to