This commit is contained in:
Leandro Ostera 2013-11-08 18:39:16 -08:00
commit bf87eb4b4d
9 changed files with 33 additions and 31 deletions

View File

@ -43,7 +43,7 @@
"use strict"; "use strict";
function DEFNODE(type, props, methods, base) { var DEFNODE = function DEFNODE(type, props, methods, base) {
if (arguments.length < 4) base = AST_Node; if (arguments.length < 4) base = AST_Node;
if (!props) props = []; if (!props) props = [];
else props = props.split(/\s+/); else props = props.split(/\s+/);
@ -918,7 +918,7 @@ var AST_True = DEFNODE("True", null, {
/* -----[ TreeWalker ]----- */ /* -----[ TreeWalker ]----- */
function TreeWalker(callback) { var TreeWalker = function TreeWalker(callback) {
this.visit = callback; this.visit = callback;
this.stack = []; this.stack = [];
}; };

View File

@ -43,7 +43,7 @@
"use strict"; "use strict";
function Compressor(options, false_by_default) { var Compressor = function Compressor(options, false_by_default) {
if (!(this instanceof Compressor)) if (!(this instanceof Compressor))
return new Compressor(options, false_by_default); return new Compressor(options, false_by_default);
TreeTransformer.call(this, this.before, this.after); TreeTransformer.call(this, this.before, this.after);

View File

@ -43,7 +43,7 @@
"use strict"; "use strict";
function OutputStream(options) { var OutputStream = function OutputStream(options) {
options = defaults(options, { options = defaults(options, {
indent_start : 0, indent_start : 0,

View File

@ -608,7 +608,9 @@ var ATOMIC_START_TOKEN = array_to_hash([ "atom", "num", "string", "regexp", "nam
/* -----[ Parser ]----- */ /* -----[ Parser ]----- */
function parse($TEXT, options) {
var parse = function parse($TEXT, options) {
options = defaults(options, { options = defaults(options, {
strict : false, strict : false,

View File

@ -43,7 +43,7 @@
"use strict"; "use strict";
function SymbolDef(scope, index, orig) { var SymbolDef = function SymbolDef(scope, index, orig) {
this.name = orig.name; this.name = orig.name;
this.orig = [ orig ]; this.orig = [ orig ];
this.scope = scope; this.scope = scope;

View File

@ -44,7 +44,7 @@
"use strict"; "use strict";
// a small wrapper around fitzgen's source-map library // a small wrapper around fitzgen's source-map library
function SourceMap(options) { var SourceMap = function SourceMap(options) {
options = defaults(options, { options = defaults(options, {
file : null, file : null,
root : null, root : null,

View File

@ -45,7 +45,7 @@
// Tree transformer helpers. // Tree transformer helpers.
function TreeTransformer(before, after) { var TreeTransformer = function TreeTransformer(before, after) {
TreeWalker.call(this); TreeWalker.call(this);
this.before = before; this.before = before;
this.after = after; this.after = after;

View File

@ -43,36 +43,36 @@
"use strict"; "use strict";
function array_to_hash(a) { var array_to_hash = function array_to_hash(a) {
var ret = Object.create(null); var ret = Object.create(null);
for (var i = 0; i < a.length; ++i) for (var i = 0; i < a.length; ++i)
ret[a[i]] = true; ret[a[i]] = true;
return ret; return ret;
}; };
function slice(a, start) { var slice = function slice(a, start) {
return Array.prototype.slice.call(a, start || 0); return Array.prototype.slice.call(a, start || 0);
}; };
function characters(str) { var characters = function characters(str) {
return str.split(""); return str.split("");
}; };
function member(name, array) { var member = function member(name, array) {
for (var i = array.length; --i >= 0;) for (var i = array.length; --i >= 0;)
if (array[i] == name) if (array[i] == name)
return true; return true;
return false; return false;
}; };
function find_if(func, array) { var find_if = function find_if(func, array) {
for (var i = 0, n = array.length; i < n; ++i) { for (var i = 0, n = array.length; i < n; ++i) {
if (func(array[i])) if (func(array[i]))
return array[i]; return array[i];
} }
}; };
function repeat_string(str, i) { var repeat_string = function repeat_string(str, i) {
if (i <= 0) return ""; if (i <= 0) return "";
if (i == 1) return str; if (i == 1) return str;
var d = repeat_string(str, i >> 1); var d = repeat_string(str, i >> 1);
@ -81,12 +81,12 @@ function repeat_string(str, i) {
return d; return d;
}; };
function DefaultsError(msg, defs) { var DefaultsError = function DefaultsError(msg, defs) {
this.msg = msg; this.msg = msg;
this.defs = defs; this.defs = defs;
}; };
function defaults(args, defs, croak) { var defaults = function defaults(args, defs, croak) {
if (args === true) if (args === true)
args = {}; args = {};
var ret = args || {}; var ret = args || {};
@ -98,14 +98,14 @@ function defaults(args, defs, croak) {
return ret; return ret;
}; };
function merge(obj, ext) { var merge = function merge(obj, ext) {
for (var i in ext) if (ext.hasOwnProperty(i)) { for (var i in ext) if (ext.hasOwnProperty(i)) {
obj[i] = ext[i]; obj[i] = ext[i];
} }
return obj; return obj;
}; };
function noop() {}; var noop = function noop() {};
var MAP = (function(){ var MAP = (function(){
function MAP(a, f, backwards) { function MAP(a, f, backwards) {
@ -155,24 +155,24 @@ var MAP = (function(){
return MAP; return MAP;
})(); })();
function push_uniq(array, el) { var push_uniq = function push_uniq(array, el) {
if (array.indexOf(el) < 0) if (array.indexOf(el) < 0)
array.push(el); array.push(el);
}; };
function string_template(text, props) { var string_template = function string_template(text, props) {
return text.replace(/\{(.+?)\}/g, function(str, p){ return text.replace(/\{(.+?)\}/g, function(str, p){
return props[p]; return props[p];
}); });
}; };
function remove(array, el) { var remove = function remove(array, el) {
for (var i = array.length; --i >= 0;) { for (var i = array.length; --i >= 0;) {
if (array[i] === el) array.splice(i, 1); if (array[i] === el) array.splice(i, 1);
} }
}; };
function mergeSort(array, cmp) { var mergeSort = function mergeSort(array, cmp) {
if (array.length < 2) return array.slice(); if (array.length < 2) return array.slice();
function merge(a, b) { function merge(a, b) {
var r = [], ai = 0, bi = 0, i = 0; var r = [], ai = 0, bi = 0, i = 0;
@ -196,13 +196,13 @@ function mergeSort(array, cmp) {
return _ms(array); return _ms(array);
}; };
function set_difference(a, b) { var set_difference = function set_difference(a, b) {
return a.filter(function(el){ return a.filter(function(el){
return b.indexOf(el) < 0; return b.indexOf(el) < 0;
}); });
}; };
function set_intersection(a, b) { var set_intersection = function set_intersection(a, b) {
return a.filter(function(el){ return a.filter(function(el){
return b.indexOf(el) >= 0; return b.indexOf(el) >= 0;
}); });
@ -210,7 +210,7 @@ function set_intersection(a, b) {
// this function is taken from Acorn [1], written by Marijn Haverbeke // this function is taken from Acorn [1], written by Marijn Haverbeke
// [1] https://github.com/marijnh/acorn // [1] https://github.com/marijnh/acorn
function makePredicate(words) { var makePredicate = function makePredicate(words) {
if (!(words instanceof Array)) words = words.split(" "); if (!(words instanceof Array)) words = words.split(" ");
var f = "", cats = []; var f = "", cats = [];
out: for (var i = 0; i < words.length; ++i) { out: for (var i = 0; i < words.length; ++i) {
@ -245,14 +245,14 @@ function makePredicate(words) {
return new Function("str", f); return new Function("str", f);
}; };
function all(array, predicate) { var all = function all(array, predicate) {
for (var i = array.length; --i >= 0;) for (var i = array.length; --i >= 0;)
if (!predicate(array[i])) if (!predicate(array[i]))
return false; return false;
return true; return true;
}; };
function Dictionary() { var Dictionary = function Dictionary() {
this._values = Object.create(null); this._values = Object.create(null);
this._size = 0; this._size = 0;
}; };

View File

@ -25,7 +25,7 @@ function tmpl() {
function log() { function log() {
var txt = tmpl.apply(this, arguments); var txt = tmpl.apply(this, arguments);
sys.puts(txt); console.log(txt);
} }
function log_directory(dir) { function log_directory(dir) {