duaraghav8 / soltar Goto Github PK
View Code? Open in Web Editor NEWGenerate Solidity Code from its AST
Home Page: https://www.npmjs.com/package/soltar
License: MIT License
Generate Solidity Code from its AST
Home Page: https://www.npmjs.com/package/soltar
License: MIT License
Possible enhancement:
Update Literal to handle Objects as well (since regex returns {})
when using regex, solidity-parser sets the Literal object's value to {}. Bug on SP side??
Hi @duaraghav8 , when I was looking up for AST to Solidity tools/libraries, soltar happens to be the first and the only result. As what it looks like, it doesn't support many new features of newer version of Solidity. Do you plan to add the support?
Thanks! :)
if (a && (b || (!c))) { foo (); }
the AST for the above, when passed to soltar.generate ()
, generates the following:
if (a && b || !c) {\n\tfoo ();\n}
Another example
(89 * 2) - (12 + (34 / (y**2))) + (23 % (2**2))
output:
89 * 2 - 12 + 34 / y ** 2 + 23 % 2 ** 2;
there should be brackets :'(
in the Type node:
{ type: 'Type', literal: 'address', members: [], array_parts: [ 5 ] };
what the fuck is members: [] for??
solidity-parser generates following representation of Hex Values:
{type: "Literal", value: '0x89'}
Need safe way to distinguish Hex values from typical strings (can't simply make a check for '0x' prefix, this can be part of a normal string also)
life is just unfair :'-(
New features are being added and the developers of solidity-parser are working hard at implementing the all in their Abstract Syntax tree. Keep up
List of (unfixed) bugs in solidity-parser
{type: "Literal", value: {}}
contract Car is Vehicle, Engine {
//definition
}
Solidity parser doesn't parse the 'is' section properly. the is Array's first object is fine (vehicle), but subsequent element is just a comma, not another object for Engine.
uint x = 2 days;
doesn't get parsed. It gives error at start of 'days'.var (x) = 100;
failing because x is surrounded by brackets (which is legal in solidity).var (x, y) = (10, 20);
is the correct syntax, not
var x, y = (10, 20);
fix
I'm trying to set this up, using the AST generated from solparse with this file, but I get the following error:
/Users/danielque/git/cryptofin-solidity/node_modules/soltar/index.js:342
GENERATOR_OBJECT [item.type] (item),
^
TypeError: GENERATOR_OBJECT[item.type] is not a function
at /Users/danielque/git/cryptofin-solidity/node_modules/soltar/index.js:342:35
at Array.forEach (<anonymous>)
at CodeGenerator.ContractStatement (/Users/danielque/git/cryptofin-solidity/node_modules/soltar/index.js:339:14)
at /Users/danielque/git/cryptofin-solidity/node_modules/soltar/index.js:830:34
at Array.forEach (<anonymous>)
at CodeGenerator.Program (/Users/danielque/git/cryptofin-solidity/node_modules/soltar/index.js:825:13)
at CodeGenerator.generateStatement (/Users/danielque/git/cryptofin-solidity/node_modules/soltar/index.js:219:26)
at CodeGenerator.generate (/Users/danielque/git/cryptofin-solidity/node_modules/soltar/index.js:228:15)
at Object.generate (/Users/danielque/git/cryptofin-solidity/node_modules/soltar/index.js:1474:4)
at Object.<anonymous> (/Users/danielque/git/cryptofin-solidity/test.js:105:31)
Without being familiar with the code, this is perhaps caused by lack of support for these?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.