You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 27, 2020. It is now read-only.
A Solidity parser built on top of a robust ANTLR4 grammar.
Usage
importparserfrom'solidity-parser-antlr';varinput=` contract test { uint256 a; function f() {} }`try{parser.parse(input)}catch(e){if(einstanceofparser.ParserError){console.log(e.errors)}}
The parse method also accepts a second argument which lets you specify the
following options, in a style similar to the esprima API:
Key
Type
Default
Description
tolerant
Boolean
false
When set to true it will collect syntax errors and place them in a list under the key errors inside the root node of the returned AST. Otherwise, it will raise a parser.ParserError.
loc
Boolean
false
When set to true, it will add location information to each node, with start and stop keys that contain the corresponding line and column numbers. Column numbers start from 0, lines start from 1.
range
Boolean
false
When set to true, it will add range information to each node, which consists of a two-element array with start and stop character indexes in the input.
varast=parser.parse('contract test { uint a; }')// output the path of each import foundparser.visit(ast,{ImportDirective: function(node){console.log(node.path)}})