Re: Allegro Wrapper?
- Posted by petelomax Sep 21, 2022
- 994 views
Right now ... I need better tools to visualize the Euphoria source code, intermediate language, and symbol table to better understand how everything works,
Indeed, having a visual display of the parse tree proved very helpful when writing the transpiler, and to a lesser/shorter term extent the token list.
It was not particularly difficult either, while this is phix and in fact p2js-specific, the main bit of code ended up being just
elsif what="PARSETREE" then sequence tree_nodes = treeify(ast) if tree_dlg=NULL then tree = IupTreeView(tree_nodes) IupSetCallback(tree, "SELECTION_CB", Icallback("selection_cb")) tree_dlg = IupDialog(tree) IupSetAttributeHandle(tree_dlg,"PARENTDIALOG",main_dlg) IupSetAttribute(tree_dlg,"TITLE","Parse Tree") IupSetAttribute(tree_dlg,"RASTERSIZE","660x830") IupSetCallback(tree_dlg, "CLOSE_CB", Icallback("close_sub_cb")) else IupTreeAddNodes(tree,tree_nodes) end if IupConfigDialogShow(config, tree_dlg, "ParseTree")
The treeify() function is a fairly trivial (and very p2js-specific) munging into a more consistent structure, and
IupTreeView()/IupTreeAddNodes() were specially written for phix, but probably quite nickable.
From further back in time, ildump.txt and list.asm contain the intermediate code and symbol table respectively,
and it probably would be nicer if they could be displayed/filtered on-screen, rather than being flat text files.