REPL code review -- ReplParser

Robert Field robert.field at oracle.com
Sat Sep 19 19:00:22 UTC 2015


On 09/11/15 08:25, Maurizio Cimadamore wrote:
>
> * ReplParser - in general it looks good. The question I have here is 
> more design-oriented: why do we need it? I believe the main use case 
> is that you need to parse the input source to be able to decide 
> between expressions and declarations. Can't we wrap the snippet in the 
> following two ways:
>
> class Temp$Decl {
>    <snippet here>
> }
>
> and:
>
> class Temp$Expr {
>    Object o = <snippet here>
> }
>
> and then see who wins? This would also require also to move the 
> wrapping logic from Eval to some earlier stage (when the input is 
> deemed complete). It's probably a very big change, so I'm merely 
> throwing this as a suggestion for future improvements - it's outside 
> the scope of the review. 

Were it so easy ;-)

Trial-and-error was the first approach I took.  Remember there are 
statements and imports.  But much more importantly the problem is 
determining "who wins".  You are likely to get errors for any number of 
reasons other than not having the snippet shoved in the right context. 
Within the processing of each type you will notice that the 
trail-and-error approach is still used in some cases to get the full 
context.  Nesting trail-and-error in trail-and-error was just too wobbly 
a foundation.

-Robert



More information about the kulla-dev mailing list