[NIT] Pretty pretting #ifFalse:ifTrue:

danielv at netvision.net.il danielv at netvision.net.il
Fri Nov 23 17:28:38 UTC 2001


Bijan Parsia <bparsia at email.unc.edu> wrote:
> It seems to me that the parse tree would need to retain source code
> coordinates to make these feasible. Hmm. The debugger must do *something*
> along these lines, in order to highlight the currently executed code, but
> I'm not sure how that works.

Yup. This is generally very nice to have, because it makes the IDE much
better connected to the code. This is how the Refactoring Browser (for
example) gives you context sensitive menus over code panes - the RB
parser records the coordinates for each node.

Examples of places that are complicated by the current state of affairs
-

* the "explain" facility
* The correction of misspelled message names
* Obviously, the debugger.

In the past I've patched T-Gen to generate parsers that record text
coordinates for each node, and used it to do cool as-you-type,
position-and-context sensitive syntax and semantic error notification on
a (somewhat) simple query language. I think only one person other than
me ever wrote a query in that tool, but it was still loads of fun... ;-)

I've often wished Squeaks parser had stored coordinates, decided to
finally do it, started looking at it again, remembered how it was
structured and why I'd gotten scared off last time (:-), and forgot
about it for while. 

I suspect basing the colorizer on the RB parser might be the easiest
solution at this time. The parser is available as a package without the
refactorings, if someone wants to try this route, so the colorizer
needn't require the whole refactoring engine and UI.

> On Mon, 19 Nov 2001, ducasse wrote:
> > We started 6 months ago to write a pretty printer based on a visitor.
> > So that we could have multiple way of enriching the tree. But this is not
> > straightforward... 
Sounds like a very good approach to decorating a parser, but without the
parse-nodes storing the text-coordinates, I don't see how it could
retain the original text (or maybe it wasn't supposed to?)

Daniel




More information about the Squeak-dev mailing list