Traverse DSL-AST and collect unique integer IDs for each node

What is the recommended way to collect unique integer IDs for selected or all nodes of an DSL program to build integer domains which are required to set up constraint solver variables?

Thx
Kai

0
2 comments
Avatar
Permanently deleted user

When you have a node you can type the slash on the right of the node, meaning "downcast to lower semantics". After that you have the method getId which return you an internal unique ID for the node

1
Avatar
Permanently deleted user

As Frederico said, you have to downcast the node to access that functionality. Assuming "node" is a node, you'll get the following:

node/.getNodeId()

However I've found that in some particular scenarios (that I've never managed to figure it out), the downcast operation is not available in the context assistant (showing only the BaseLanguage 'divide' and the 'divide and assign' concepts). In those rare scenarios, just surround the node with parenthesis and try again... It normally does the trick. The code will look like the following:

(node)/.getNodeId()

 

Regards,

 

Sérgio Ribeiro

Porto - Portugal.

 

0

Please sign in to leave a comment.