Workspace AST representation

144 views
Skip to first unread message

Mauricio Verano Merino

unread,
Nov 20, 2018, 11:08:29 AM11/20/18
to Blockly
Hi,
I'm wondering if it is possible to obtain the AST representation of a current program in my workspace. Does anyone know if it possible and how?

Thanks,
Mauricio

Erik Pasternak

unread,
Nov 20, 2018, 12:16:52 PM11/20/18
to Blockly
Do you mean the block hierarchy or the AST for the generated text code? If the former, you can call workspace.getTopBlocks() to get all the root blocks and you can traverse them as a tree by following their connections. For the latter, Blockly just generates text so there isn't an AST for the output until the text is parsed by another runtime.
Reply all
Reply to author
Forward
0 new messages