This repository was archived by the owner on Sep 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
Tokenize function is not working #94
Copy link
Copy link
Open
Description
Using version 0.4.11.
Reproduction steps: install the library and run:
const parser = require('solidity-parser-antlr')
const tokens = parser.tokenize('contract Foo {}')Throws this error:
Error: ENOENT: no such file or directory, open <root>/node_modules/solidity-parser-antlr/lib/Solidity.tokens'
Possible fix
I cloned the repo and made two modifications:
- Change the build script to
rm -rf dist && babel --out-dir=dist src --copy-files(adds--copy-files) - In
src/tokens.js, make this change:
diff --git a/src/tokens.js b/src/tokens.js
index 10836dd..f47b0ac 100644
--- a/src/tokens.js
+++ b/src/tokens.js
@@ -55,7 +55,7 @@ function getTokenType(value) {
}
function getTokenTypeMap() {
- const filePath = path.join(__dirname, '../lib/Solidity.tokens')
+ const filePath = path.join(__dirname, './lib/Solidity.tokens')
return fs
.readFileSync(filePath)This worked for me, but I'm not sure if it may have another implications. If you want, I can create a PR with this change.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels