Skip to content

Commit 8c18983

Browse files
authored
v1.0.2 (#7)
* ci(actions): update workflow * fix ci * build(entrypoint): fix * feat(tracer): parser tracer * fix(npm): package * Release 1.0.2 * fix: bin
1 parent 1258d15 commit 8c18983

File tree

6 files changed

+205
-27
lines changed

6 files changed

+205
-27
lines changed

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cSpell.words": [
3+
"pegis",
4+
"pegjs"
5+
]
6+
}

cmd.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env node
2+
3+
"use strict";
4+
5+
(function() {
6+
var SolidityParser, echo, file, fs, i, len, ref, src;
7+
8+
fs = require('fs');
9+
10+
SolidityParser = require("./index.js");
11+
12+
echo = function(msg) {
13+
return process.stdout.write(JSON.stringify(msg, null, 2) + '\n');
14+
};
15+
16+
if (process.argv.length > 2) {
17+
ref = process.argv.slice(2);
18+
for (i = 0, len = ref.length; i < len; i++) {
19+
file = ref[i];
20+
src = fs.readFileSync(file, 'utf8');
21+
try {
22+
echo(SolidityParser.parse(src));
23+
} catch (err) {
24+
process.stderr.write(
25+
err.name === 'SyntaxError'
26+
? "Location: " + JSON.stringify(err.location, null, 4) + "\n" + err
27+
: err.name + ': ' + err.message
28+
);
29+
}
30+
}
31+
} else {
32+
echo("Solidity Parser: file...");
33+
}
34+
35+
}).call(this);

explore.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
var solExplore = require ('sol-explore'),
2+
solparse = require ('pegjs-solidity');
3+
4+
module.exports = {
5+
6+
version: require ('./package.json').version,
7+
8+
findImports: function (sourceCode) {
9+
10+
var importedFiles = [], AST;
11+
12+
try {
13+
AST = solparse.parse (sourceCode);
14+
} catch (e) {
15+
throw new Error (
16+
'An error occured while trying to parse the code:\n' + e
17+
);
18+
}
19+
20+
solExplore.traverse (AST, {
21+
22+
enter: function (node) {
23+
if (node.type === 'ImportStatement') {
24+
importedFiles.push (node.from);
25+
}
26+
}
27+
28+
});
29+
30+
return importedFiles;
31+
32+
}
33+
34+
};

package-lock.json

Lines changed: 102 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
{
2-
"name": "pegis-solidity",
3-
"version": "2.1.0",
2+
"name": "pegjs-solidity",
3+
"version": "1.0.2",
44
"description": "pegjs grammar for solidity parsing",
55
"main": "index.js",
66
"bin": {
7-
"pegis-solidity": "./cli.js"
7+
"pegjs-solidity": "./cli.js"
88
},
99
"directories": {
1010
"lib": "lib",
1111
"test": "test"
1212
},
1313
"dependencies": {
1414
"peggy": "^1.2.0",
15+
"solc": "^0.6.12",
1516
"ts-pegjs": "^1.1.1",
1617
"yargs": "^16.1.0"
1718
},
@@ -33,7 +34,6 @@
3334
"tracer": "./node_modules/.bin/peggy --trace --output parser-trace.js solidity.pegjs",
3435
"lint": "npx eslint .",
3536
"run": "npm run build && npm run compile",
36-
"format": "npx prettier --config .prettierrc.json --write .",
3737
"test": "npx mocha --timeout 5000 --reporter spec"
3838
},
3939
"repository": {
@@ -51,7 +51,7 @@
5151
"coverage"
5252
],
5353
"author": "SEE CONTRIBUTORS",
54-
"license": "ISC",
54+
"license": "MIT",
5555
"bugs": {
5656
"url": "https://github.com/sambacha/solidity-pegjs-parser/issues"
5757
},

0 commit comments

Comments
 (0)