Code Monkey home page Code Monkey logo

solidity-antlr4's Introduction

solidity-antlr4

Build Status

Solidity grammar for ANTLR4

Author

Federico Bond (@federicobond)

License

MIT

solidity-antlr4's People

Contributors

domainexpert avatar federicobond avatar frangio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

solidity-antlr4's Issues

Allow `from` as identifier

from is not actually a language keyword. See here.

We can either modify our import rules to use an Identifier or turn the lexer rule for Identifier into a parser rule that accepts either from or keyword. Solidity uses the first approach.

Add all reserved keywords

The list at the official documentation mentions these.

abstract, after, case, catch, default, final, in, inline, interface, let, match, 
null, of, pure, relocatable, static, switch, try, type, typeof, view.

Make sure it's updated with the implementation.

Add support for internal types

In the following example, the field data in the User contract is defined using IntegerSet.data type. Taken from the Solidity Features page.

pragma solidity ^0.4.4;

library IntegerSet
{
  struct data
  {
    mapping(uint => uint) index;
    uint[] items;
    uint size;
  }
  function insert(data storage self, uint value) returns (bool alreadyPresent)
  {
    uint index = self.index[value];
    if (index > 0)
      return true;
    else
    {
      if (self.items.length == 0) self.items.length = 1;
      index = self.items.length++;
      self.items[index] = value;
      self.index[value] = index;
      self.size++;
      return false;
    }
  }
  function remove(data storage self, uint value) returns (bool success)
  {
    uint index = self.index[value];
    if (index == 0)
      return false;
    delete self.index[value];
    delete self.items[index];
    self.size --;
  }
  function contains(data storage self, uint value) returns (bool)
  {
    return self.index[value] > 0;
  }
  function iterate_start(data storage self) returns (uint index)
  {
    return iterate_advance(self, 0);
  }
  function iterate_valid(data storage self, uint index) returns (bool)
  {
    return index < self.items.length;
  }
  function iterate_advance(data storage self, uint index) returns (uint r_index)
  {
    index++;
    while (iterate_valid(self, index) && self.index[self.items[index]] == index)
      index++;
    return index;
  }
  function iterate_get(data storage self, uint index) returns (uint value)
  {
      return self.items[index];
  }
}

contract User
{
  IntegerSet.data data;
  function insert(uint v) returns (uint size)
  {
    IntegerSet.insert(data, v);
    return data.size;
  }
  function sum() returns (uint s)
  {
    for (var i = IntegerSet.iterate_start(data); IntegerSet.iterate_valid(data, i); i = IntegerSet.iterate_advance(data, i))
      s += IntegerSet.iterate_get(data, i);
  }
}

Listening for `functionCall`?

Hi, I don't know much about ANTLR so sorry in advance if this doesn't make sense.

I want to add a Listener for functionCall, but those nodes are interpreted as expressions instead. I guess this happens because one of the rules for expression (the fourth one) has the same definition as functionCall (and that rule is not inside expression). Maybe replacing that for functionCall will do the trick?

Thanks!

newest version

Sorry to bother you, where can I find the newest version of this Solidity.g4 file?

Question: what is nameValueList ?

I am now trying to understand what the field "names" in a functionCall node is for. So, I realized it has something to do with nameValueList defined in this grammar at

: '{' nameValueList? '}'
. But, I don't think I have seen this function call syntax or maybe I understood this grammar wrongly. Would be great if anyone can explain this.

Thanks

Relicense project to MIT

Pinging @domainexpert and @frangio. Several people have approached me in the past with the intention of building tools with a more permissive license on top of this code. I would like to get your opinions or consent as collaborators to relicense this project to MIT.

Let me know if any of you disagrees or state your consent explicitly. Thank you in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.