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

Re: SableCC Thoughts Part II



Dan Sandberg wrote:
> 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.

I don't know the answer.  It really depends on how a given tool would
interpret the specification.  My point was that it is not as intuitive
as you thought it was.  The biggest problem is that a given tool will
pick one choice, and it is very unlikely that you could know which one
by simply looking at the grammar (specially in presence of deep
recursive rules).  So, the average compiler programmer will probably
again expect a different behavior of his parser than the one provided,
without knowing it.  This, as usual, leads to very difficult to tack
bugs.  This is why I would like to find another approach to
error-recovery, one that provides good software engineering, as
currently does SableCC in regards of grammar specification and compiler
implementation (on a clean AST).

> 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 am open to suggestions.  I would ideally like to have the parser do
some automated syntax recovery, then yield an AST for the compiler
programmer.  The programmer can then analyze the AST and take the
appropriate "high-level" decisions on how to handle error nodes.

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

Your're welcome:-)

Etienne
-- 
----------------------------------------------------------------------
Etienne M. Gagnon, M.Sc.                     e-mail: egagnon@j-meg.com
Author of SableCC:                             http://www.sablecc.org/
and SableVM:                                   http://www.sablevm.org/