Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ast representation of lambda function

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.

like image 235
Uko Avatar asked Oct 23 '12 14:10

Uko


1 Answers

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.

like image 160
Lukas Renggli Avatar answered Sep 21 '22 10:09

Lukas Renggli