Skip to content

Commit

Permalink
feat(lexer): added lexer souce code
Browse files Browse the repository at this point in the history
  • Loading branch information
KFlash committed May 7, 2019
1 parent cb8d15b commit ade6e8f
Show file tree
Hide file tree
Showing 36 changed files with 4,567 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# http://EditorConfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[ts]
indent_size = 2
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/dist
node_modules
/coverage
/.nyc_output
/.rpt2_cache
/packages/*/node_modules
/packages/*/npm-debug.log
/packages/*/build
/packages/*/lib
/packages/*/coverage
/packages/*/.nyc_output
/packages/*/.rpt2_cache
yarn.lock
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.rollupcache
.fuzz-output
.DS_Store
cherow-rewritten.js

# fuzz output
/packages/cherow/.fuzz-output/
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock = true
11 changes: 11 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
bench/v1.6.2/
bench/v2/
bench/v8-native-calls.js
node_modules/
dist/
src/token.ts
src/common.ts
src/chars.ts
src/lexer/charClassifier.ts
src/unicode.ts
package-lock.json
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"christian-kohler.path-intellisense",
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode",
"joelday.docthis",
"steoates.autoimport"
]
}
47 changes: 47 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}\\dist\\umd\\cherow.js",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": [
"${workspaceFolder}/build/**/*.js"
]
},
{
"type": "node",
"request": "launch",
"name": "Launch mocha tests",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"env": {
"TS_NODE_PROJECT": "${workspaceRoot}/test/tsconfig.json"
},
"args": [
"${workspaceRoot}/test/**/*.ts",
"-c",
"-R",
"progress",
"-r",
"source-map-support/register",
"-r",
"ts-node/register",
"--recursive",
"--globals",
"expect",
"--timeout",
"999999",
"--watch",
"--watch-extensions",
"ts"
],
"cwd": "${workspaceRoot}",
"internalConsoleOptions": "openOnSessionStart"
}
]
}
18 changes: 18 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"typescript.tsdk": "./node_modules/typescript/lib",
"tslint.nodePath": "./node_modules/tslint/bin/tslint",
"tslint.exclude": [
"**/node_modules/**",
"**/dist/**",
"**/build/**",
"packages/*/test/**"
],
"emmet.triggerExpansionOnTab": true,
"search.exclude": {
"**/node_modules": true,
"**/dist": true,
"**/build": true,
"**/.vscode": true
},
"prettier.singleQuote": true
}
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ISC License

Copyright (c) 2019 and later, KFlash and others.

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 changes: 19 additions & 0 deletions package-lock.json

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

96 changes: 96 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"name": "meriyah",
"version": "0.1.0",
"description": "Fast and lightweight, standard-compliant javascript parser written in ECMAScript",
"main": "dist/meriyah.umd.js",
"module": "dist/meriyah.esm.js",
"jsnext:main": "dist/meriyah.esm.js",
"browser": "dist/meriyah.umd.js",
"types": "dist/meriyah.d.ts",
"typings": "dist/meriyah.d.ts",
"author": "KFlash",
"license": "ISC",
"homepage": "https://github.com/meriyah/meriyah",
"repository": {
"type": "git",
"url": "https://github.com/meriyah/meriyah"
},
"bugs": {
"url": "https://github.com/meriyah/meriyah/issues"
},
"keywords": [
"parsing",
"ecmascript",
"typescript",
"javascript",
"lexer",
"scanner",
"parser",
"performance",
"estree",
"es2018",
"es2019",
"es2020",
"esnext",
"ast",
"lightweight"
],
"files": [
"dist",
"src",
"README.md",
"CHANGELOG.md",
"LICENSE.md"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "tsc",
"build:watch": "tsc -w",
"lint": "cross-env tslint -p tsconfig.json -t stylish",
"prettier": "node ./scripts/prettier.js write-changed",
"prettier-all": "node ./scripts/prettier.js write",
"bundle": "cross-env rimraf dist && node scripts/bundle.js",
"bundle:bench": "cross-env rimraf dist && node scripts/bundle.js bench",
"test": "cross-env TS_NODE_PROJECT=\"test/tsconfig.json\" mocha \"test/**/*.ts\" -c -R progress -r ts-node/register -r source-map-support/register --recursive --globals expect",
"test:watch": "npm run test -- --watch --watch-extensions ts",
"test:verbose": "npm run test -- -R spec",
"test:watch:verbose": "npm run test:watch -- -R spec",
"prepare-nightly": "node scripts/bump-dev-version",
"coverage": "cross-env TS_NODE_PROJECT=\"test/tsconfig.json\" nyc -n \"src/**/*.ts\" -e .ts -i ts-node/register -r text-summary -r lcov -r html npm test",
"post_coverage": "cross-env cat ./coverage/lcov.info | coveralls"
},
"devDependencies": {
"@types/mocha": "^5.2.6",
"@types/node": "^12.0.0",
"coveralls": "^3.0.3",
"cross-env": "^5.2.0",
"husky": "^2.2.0",
"mocha": "^6.1.4",
"nyc": "^14.1.0",
"path": "^0.12.7",
"prettier": "^1.17.0",
"rimraf": "^2.6.3",
"rollup": "^1.11.3",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-terser": "^4.0.4",
"rollup-plugin-typescript2": "^0.21.0",
"source-map-support": "^0.5.12",
"ts-node": "^8.1.0",
"tsconfig-paths": "^3.8.0",
"tslint": "^5.16.0",
"tslint-microsoft-contrib": "^6.1.1",
"typescript": "^3.4.5",
"unexpected": "^11.4.1",
"unicode-12.0.0": "^0.8.0"
},
"husky": {
"hooks": {
"pre-commit": "node ./scripts/prettier.js check-changed"
}
},
"dependencies": {
"tslib": "^1.9.3"
}
}
10 changes: 10 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

module.exports = {
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'none',
useTabs: false,
printWidth: 120
};
64 changes: 64 additions & 0 deletions scripts/bump-dev-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const { readFile, writeFile } = require('fs');
const project = require('./project');

async function loadPackageJson(isLockfile) {
const file = isLockfile ? 'package-lock.json' : 'package.json';
return new Promise((resolve, reject) => {
readFile(project[file].path, (err, data) => {
if (err) {
reject(err);
}
const str = data.toString('utf8');
const json = JSON.parse(str);
resolve(json);
});
});
}

async function savePackageJson(pkg, isLockfile) {
const file = isLockfile ? 'package-lock.json' : 'package.json';
return new Promise((resolve, reject) => {
const str = JSON.stringify(pkg, null, 2);
writeFile(project[file].path, str, { encoding: 'utf8' }, err => {
if (err) {
reject(err);
}
resolve();
});
});
}

async function run() {
versionRegExp = /(\d+)\.(\d+)\.(\d+)($|\-)/;
const match = project.pkg.version.match(versionRegExp);
if (match === null) {
throw new Error(`package.json 'version' should match ${versionRegExp}`);
}
const major = match[1];
const minor = match[2];
const patch = match[3];
console.log(`current version: ${major}.${minor}.${patch}`);

const raw = new Date()
.toISOString()
.replace(/:|T|\.|-/g, '')
.slice(0, 8);
const y = raw.slice(0, 4);
const m = raw.slice(4, 6);
const d = raw.slice(6, 8);
const datestamp = `${y}${m}${d}`;
const newVersion = `${major}.${minor}.${patch}-dev.${datestamp}`;
console.log(`new version: ${newVersion}`);

const packageJson = await loadPackageJson(false);
packageJson.version = newVersion;
await savePackageJson(packageJson, false);

const packageLockJson = await loadPackageJson(true);
packageLockJson.version = newVersion;
await savePackageJson(packageLockJson, true);
}

run().then(() => {
console.log(`Done.`);
});
Loading

0 comments on commit ade6e8f

Please sign in to comment.