Skip to content
This repository has been archived by the owner on Sep 27, 2020. It is now read-only.

Tokenize function is not working #94

Open
fvictorio opened this issue Nov 14, 2019 · 0 comments
Open

Tokenize function is not working #94

fvictorio opened this issue Nov 14, 2019 · 0 comments

Comments

@fvictorio
Copy link
Contributor

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:

  1. Change the build script to rm -rf dist && babel --out-dir=dist src --copy-files (adds --copy-files)
  2. 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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant