UNPKG

sol-explore

Version:

Traversal functions for solidity-parser generated AST

68 lines (65 loc) 1.67 kB
<html> <head> <script src="sol-explore-bundle.js"></script> </head> <body> <script> let AST = { "type": "Program", "body": [ { "type": "ContractStatement", "name": "Axd", "is": [], "body": [ { "type": "FunctionDeclaration", "name": "hello", "params": null, "modifiers": null, "body": { "type": "BlockStatement", "body": [ { "type": "IfStatement", "test": { "type": "Literal", "value": true }, "consequent": { "type": "BlockStatement", "body": [ { "type": "ExpressionStatement", "expression": { "type": "CallExpression", "callee": { "type": "Identifier", "name": "world" }, "arguments": [] } } ] }, "alternate": null } ] }, "is_abstract": false } ] } ] }; SolExplore.traverse (AST, { enter: function (node) { console.log ('entering: ', node.type); }, leave: function (node) { console.log ('leaving: ', node.type); } }); </script> </body> </body>