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

Re: SableCC Thoughts Part II

> OK...  Let's pick a little more elaborate example...
> d = a | 'j' 'k';
> a = 'j' 'b' | 'c' | error 'eol';
> (where x is a production, and 'x' is a token).
> input string:  'j' 'e' 'eol'
> what should happen?

Ok, I admit the behavior is by no means obvious on this one.  I would
think this should also be a parse error, because it seems like if 'where
we are' in the parse is ambiguous, it would be safer to assume we are in
the least specific (most ancestral) production. It seems that for sure
we have entered the d production, but we are not sure whether we should
be in the a production.  Please let me know if I'm right, I'm curious. 
Regardless, I do understand your point.  So what method are you
suggesting for error recovery?  It seems like there is a trade-off
between intuitive non-powerful unambiguous error-recovery, and
unintuitive, powerful, ambiguous error-recovery.  Is that the main
decision you are making?  Or are you considering including a bunch of
different error-recovery techniques?

> I invite you to browser the comp.compiler newsgroup archives.  The
> question of error recovery comes up every now and then.  Many compiler
> gurus have reported on the advantages and failures of various
> approaches.

I've been looking into it a bit.  It definitely seems like there are
many ways to do it and no concensus on the best one.  I suppose without
semantics the best you can do is an educated guess based on the
statistical frequency of different kinds of errors.  I suppose that
explains your previous suggestion pretty well :)  

BTW, I realize you know much more about this area than I do and I
appreciate you taking the time to explain things.