[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master bd8fc87 034/271: Restore test files. Start on uglify token
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master bd8fc87 034/271: Restore test files. Start on uglify tokenizer. |
Date: |
Thu, 05 Feb 2015 18:29:34 +0000 |
branch: master
commit bd8fc87a46962e31e9a363bf0eb35ef49f489c21
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Restore test files. Start on uglify tokenizer.
---
.gitignore | 3 ++
Makefile | 8 ++++++
package.json | 29 +++++++++++++++++++++++
scopify.js | 51 +++++++++++++++++++++++++++++++++++++++++
test/context-coloring-test.el | 3 ++
test/fixtures/monad.js | 9 +++++++
test/scopify.js | 16 +++++++++++++
7 files changed, 119 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b7ec7e5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.elc
+*.log
+node_modules/
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..8b142f2
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,8 @@
+all:
+ exit
+
+test:
+ mocha
+ emacs -batch -l ert -l test/context-coloring-test.el -f
ert-run-tests-batch-and-exit
+
+.PHONY: all test clean
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..c5cd241
--- /dev/null
+++ b/package.json
@@ -0,0 +1,29 @@
+{
+ "name": "context-coloring",
+ "version": "0.0.0",
+ "description": "JavaScript syntax highlighting for grown-ups.",
+ "main": "index.js",
+ "directories": {
+ "test": "test"
+ },
+ "scripts": {
+ "test": "make test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/jacksonrayhamilton/context-coloring.git"
+ },
+ "author": "Jackson Ray Hamilton",
+ "license": "GPL-3.0+",
+ "bugs": {
+ "url": "https://github.com/jacksonrayhamilton/context-coloring/issues"
+ },
+ "homepage": "https://github.com/jacksonrayhamilton/context-coloring",
+ "devDependencies": {
+ "matcha": "^0.6.0",
+ "mocha": "^2.0.1"
+ },
+ "dependencies": {
+ "uglify-js": "^2.4.15"
+ }
+}
diff --git a/scopify.js b/scopify.js
new file mode 100644
index 0000000..1d21142
--- /dev/null
+++ b/scopify.js
@@ -0,0 +1,51 @@
+/*jslint node: true */
+
+'use strict';
+
+var UglifyJS = require('uglify-js'),
+ whole = '';
+
+process.stdin.setEncoding('utf8');
+
+process.stdin.on('readable', function () {
+ var chunk = process.stdin.read();
+ if (chunk !== null) {
+ whole += chunk;
+ }
+});
+
+process.stdin.on('end', function () {
+ var scopes = [],
+ symbols = [],
+ toplevel = UglifyJS.parse(whole),
+ walker = new UglifyJS.TreeWalker(function (node) {
+ if (node instanceof UglifyJS.AST_Scope) {
+ if (node.level === undefined) {
+ node.level = node.parent_scope ? node.parent_scope.level +
1 : 0;
+ scopes.push([node.level,
+ node.start.pos,
+ node.end.endpos]);
+ }
+ } else if (node instanceof UglifyJS.AST_Symbol) {
+ symbols.push([node.thedef.scope.level,
+ node.start.pos,
+ node.end.endpos]);
+ }
+ });
+ toplevel.figure_out_scope();
+ toplevel.walk(walker);
+ console.log('scopes', scopes);
+ console.log('symbols', symbols);
+ // TODO: Flatten a monad.
+ // scopes [ [ 0, 0, 206 ], [ 1, 0, 206 ], [ 2, 30, 203 ], [ 3, 115, 174 ] ]
+ // symbols [ [ 0, 9, 14 ],
+ // [ 2, 39, 43 ],
+ // [ 2, 44, 49 ],
+ // [ 2, 65, 70 ],
+ // [ 0, 73, 79 ],
+ // [ 2, 102, 107 ],
+ // [ 3, 125, 129 ],
+ // [ 3, 152, 156 ],
+ // [ 2, 157, 162 ],
+ // [ 2, 191, 196 ] ]
+});
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
new file mode 100644
index 0000000..7bd0b2c
--- /dev/null
+++ b/test/context-coloring-test.el
@@ -0,0 +1,3 @@
+(ert-deftest context-coloring-test-color ()
+ "Tests something. Not sure what yet."
+ (should (equal t t)))
diff --git a/test/fixtures/monad.js b/test/fixtures/monad.js
new file mode 100644
index 0000000..4a2e19c
--- /dev/null
+++ b/test/fixtures/monad.js
@@ -0,0 +1,9 @@
+function MONAD() {
+ return function unit(value) {
+ var monad = Object.create(null);
+ monad.bind = function (func) {
+ return func(value);
+ };
+ return monad;
+ };
+}
diff --git a/test/scopify.js b/test/scopify.js
new file mode 100644
index 0000000..4525199
--- /dev/null
+++ b/test/scopify.js
@@ -0,0 +1,16 @@
+/*jslint node: true */
+/*global describe, it */
+
+'use strict';
+
+var assert = require('assert');
+
+describe('scopify', function () {
+
+ it('should work', function () {
+
+ assert.strictEqual(true, true);
+
+ });
+
+});
- [elpa] master 222276b 001/271: Init., (continued)
- [elpa] master 222276b 001/271: Init., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 09166f9 021/271: Some progress, probably have to switch back to lexical., Jackson Ray Hamilton, 2015/02/05
- [elpa] master e448e2f 025/271: Cancelling working., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 97194c7 023/271: Apply tokens with lexically-bound buffer as current., Jackson Ray Hamilton, 2015/02/05
- [elpa] master b4b86ac 033/271: Fix after-change-functions with add-hook. Fix nulls., Jackson Ray Hamilton, 2015/02/05
- [elpa] master cce215d 030/271: Add readme., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 169b1f4 028/271: Set JSLint options to not care., Jackson Ray Hamilton, 2015/02/05
- [elpa] master df36161 031/271: Fix screenshot link., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 16e984c 039/271: Update installation instructions., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 3e6f2cf 037/271: Cleanup., Jackson Ray Hamilton, 2015/02/05
- [elpa] master bd8fc87 034/271: Restore test files. Start on uglify tokenizer.,
Jackson Ray Hamilton <=
- [elpa] master 099e8c1 003/271: Write basic tokenizer cli., Jackson Ray Hamilton, 2015/02/05
- [elpa] master fef44f5 038/271: Fix broken link., Jackson Ray Hamilton, 2015/02/05
- [elpa] master e4ee2ec 042/271: Catch parse errors., Jackson Ray Hamilton, 2015/02/05
- [elpa] master d372de1 029/271: Clean up cruft., Jackson Ray Hamilton, 2015/02/05
- [elpa] master b1b7f9d 032/271: Optimize tokens by connecting tail ends., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 2cdd91e 043/271: Write new scopifier with comment detection., Jackson Ray Hamilton, 2015/02/05
- [elpa] master eb14005 041/271: Rename scopify to scopifier. Use vectors., Jackson Ray Hamilton, 2015/02/05
- [elpa] master f482c62 035/271: Use remove-text-properties as a temporary comment fix., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 615163a 045/271: Update screenshot., Jackson Ray Hamilton, 2015/02/05
- [elpa] master f4e075f 047/271: Readme updates., Jackson Ray Hamilton, 2015/02/05