Question

I'm developing and Abstract Syntax Tree meta-model for a smalltalk and right now I have troubles with modeling a blocks. They are sort of literals but on the other hand they are behavioral entities like methods. Blocks are sort of lambda functions so maybe someone had better practice of working with them.

I'll be thankful for any advice.

Was it helpful?

Solution

The Refactoring Browser has a very nice AST, have a look at its implementation.

Regarding your question: The Refactoring Browser extracts the shared parts of blocks and methods into a separate node type called SequenceNode. The sequence node models the temps and the sequence of statements. The block node then wraps the sequence node, adds the arguments, and inherits the shared behaviour of value nodes. The method node wraps the sequence node and adds method name, arguments, pragmas, etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top