Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and add browser support for tokenize function #1

Merged
merged 4 commits into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"presets": ["env"]
"presets": ["env"],
"plugins": [
["babel-plugin-inline-import", {
"extensions": [".tokens"]
}]
]
}
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"max-len": 2
},
"parserOptions": {
"ecmaVersion": 2017
"ecmaVersion": 2017,
"sourceType": "module"
},
"env": {
"es6": true,
Expand Down
33 changes: 33 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"types": "./index.d.ts",
"scripts": {
"antlr4": "sh scripts/antlr4.sh",
"build": "rm -rf dist && babel --out-dir=dist src",
"build": "rm -rf dist && babel --out-dir=dist src --copy-files",
"prepare": "yarn build",
"prettier": "find src -name *.js | egrep -v '^src/(lib|antlr4)/' | xargs prettier --no-semi --single-quote --write",
"eslint": "eslint src",
"pretest": "eslint src && tslint-config-prettier-check ./tslint.json",
"test": "nyc mocha",
"test": "nyc mocha --require babel-register",
"tslint": "tslint-config-prettier-check ./tslint.json"
},
"author": [
Expand All @@ -26,6 +26,7 @@
"license": "MIT",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-plugin-inline-import": "^3.0.0",
"babel-preset-env": "^1.7.0",
"chai": "^4.2.0",
"eslint": "^6.2.2",
Expand Down
9 changes: 2 additions & 7 deletions src/tokens.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const fs = require('fs')
const path = require('path')
import tokens from './lib/Solidity.tokens'

const TYPE_TOKENS = [
'var',
Expand Down Expand Up @@ -55,11 +54,7 @@ function getTokenType(value) {
}

function getTokenTypeMap() {
const filePath = path.join(__dirname, '../lib/Solidity.tokens')

return fs
.readFileSync(filePath)
.toString('utf-8')
return tokens
.split('\n')
.map(line => rsplit(line, '='))
.reduce((acum, [value, key]) => {
Expand Down