Pregunta

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.

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top