All Projects → federicobond → Solidity Parser Antlr

federicobond / Solidity Parser Antlr

Licence: mit
A Solidity parser for JS built on top of a robust ANTLR4 grammar

Programming Languages

javascript
184084 projects - #8 most used programming language
solidity
1140 projects

Projects that are alternatives of or similar to Solidity Parser Antlr

Mention
Twitter like mentions and #hashtags parser for Go(Golang)
Stars: ✭ 99 (-10.81%)
Mutual labels:  parser
Simplepie
A simple Atom/RSS parsing library for PHP.
Stars: ✭ 1,389 (+1151.35%)
Mutual labels:  parser
Forge
Functional style JSON parsing in Kotlin
Stars: ✭ 106 (-4.5%)
Mutual labels:  parser
Rslint
A (WIP) Extremely fast JavaScript and TypeScript linter and Rust crate
Stars: ✭ 1,377 (+1140.54%)
Mutual labels:  parser
Nodable
a node-able bidirectionnal expression editor.
Stars: ✭ 103 (-7.21%)
Mutual labels:  parser
Tree Sitter Javascript
Javascript grammar for tree-sitter
Stars: ✭ 103 (-7.21%)
Mutual labels:  parser
Nessus map
Parse .nessus file(s) and shows output in interactive UI
Stars: ✭ 97 (-12.61%)
Mutual labels:  parser
Sywac
🚫 🐭 Asynchronous, single package CLI framework for Node
Stars: ✭ 109 (-1.8%)
Mutual labels:  parser
Pynlp
A pythonic wrapper for Stanford CoreNLP.
Stars: ✭ 103 (-7.21%)
Mutual labels:  parser
Rdflib
RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.
Stars: ✭ 1,584 (+1327.03%)
Mutual labels:  parser
Fcc
Fedjmike's C Compiler
Stars: ✭ 101 (-9.01%)
Mutual labels:  parser
Yamldotnet
YamlDotNet is a .NET library for YAML
Stars: ✭ 1,382 (+1145.05%)
Mutual labels:  parser
Sparse
Sparse is a simple parser-combinator library written in Swift.
Stars: ✭ 104 (-6.31%)
Mutual labels:  parser
Vue Docgen Api
Toolbox to extract information from Vue component files for documentation generation purposes.
Stars: ✭ 100 (-9.91%)
Mutual labels:  parser
Cppcmb
A generic C++17 parser-combinator library with a natural grammar notation.
Stars: ✭ 108 (-2.7%)
Mutual labels:  parser
Regexpp
The regular expression parser for ECMAScript.
Stars: ✭ 97 (-12.61%)
Mutual labels:  parser
Inih
Simple .INI file parser in C, good for embedded systems
Stars: ✭ 1,394 (+1155.86%)
Mutual labels:  parser
Flap
Fortran command Line Arguments Parser for poor people
Stars: ✭ 109 (-1.8%)
Mutual labels:  parser
Plyara
Parse YARA rules and operate over them more easily.
Stars: ✭ 108 (-2.7%)
Mutual labels:  parser
Endbasic
BASIC environment with a REPL, a web interface, and RPi support written in Rust
Stars: ✭ 106 (-4.5%)
Mutual labels:  parser

solidity-parser-antlr

npm Build Status

A Solidity parser built on top of a robust ANTLR4 grammar.

Usage

import parser from 'solidity-parser-antlr';

var input = `
    contract test {
        uint256 a;
        function f() {}
    }
`
try {
    parser.parse(input)
} catch (e) {
    if (e instanceof parser.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.

Example with location information

parser.parse('contract test { uint a; }', { loc: true })

// { type: 'SourceUnit',
//   children:
//    [ { type: 'ContractDefinition',
//        name: 'test',
//        baseContracts: [],
//        subNodes: [Array],
//        kind: 'contract',
//        loc: [Object] } ],
//   loc: { start: { line: 1, column: 0 }, end: { line: 1, column: 24 } } }

Example using a visitor to walk over the AST

var ast = parser.parse('contract test { uint a; }')

// output the path of each import found
parser.visit(ast, {
  ImportDirective: function(node) {
    console.log(node.path)
  }
})

Author

Federico Bond (@federicobond)

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].