mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-14 01:07:55 -05:00
Compare commits
140 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f26d33d418 | ||
|
|
cea773ec81 | ||
|
|
98dd1bf8e8 | ||
|
|
56d75baac7 | ||
|
|
0872c3d13d | ||
|
|
5095e02b62 | ||
|
|
874628b1d0 | ||
|
|
ff9d5117f9 | ||
|
|
10aca2a38e | ||
|
|
2c4d437e98 | ||
|
|
c0c13c1977 | ||
|
|
6d9553a016 | ||
|
|
66716cd730 | ||
|
|
f588ecb288 | ||
|
|
dc3e177811 | ||
|
|
2eef667916 | ||
|
|
617a932e89 | ||
|
|
beac56d4d5 | ||
|
|
cc98e99070 | ||
|
|
93e4eeafed | ||
|
|
efdc67241a | ||
|
|
24e8f1c98f | ||
|
|
2d1a6fa6ec | ||
|
|
3d7d68a766 | ||
|
|
342b395b0a | ||
|
|
75ae45e2bb | ||
|
|
1f197fcc1b | ||
|
|
e339f5f2da | ||
|
|
c37f284771 | ||
|
|
585298dc17 | ||
|
|
2087923163 | ||
|
|
b58772e8a7 | ||
|
|
769f02ec05 | ||
|
|
52b1749d57 | ||
|
|
ba85a38cb0 | ||
|
|
c0d44b1abd | ||
|
|
0262322400 | ||
|
|
8e8f6d13bd | ||
|
|
b6667f0735 | ||
|
|
99ea1c7a39 | ||
|
|
27fd65390a | ||
|
|
79a6d89849 | ||
|
|
6fb5833843 | ||
|
|
5494ac13ee | ||
|
|
300faf401c | ||
|
|
f2c6066103 | ||
|
|
2a5320fd2b | ||
|
|
36695540fc | ||
|
|
fc0c4fdd5f | ||
|
|
ebc172d1ee | ||
|
|
4e6b6678f7 | ||
|
|
378a04e48c | ||
|
|
1e62781759 | ||
|
|
234adef20c | ||
|
|
8b463cd3ad | ||
|
|
ce10a463f3 | ||
|
|
140a73dca7 | ||
|
|
46d16b5c49 | ||
|
|
d16cf19c15 | ||
|
|
edbb9a77e7 | ||
|
|
cc4c3b2606 | ||
|
|
3a2888f97a | ||
|
|
bd17cc9b3c | ||
|
|
0a3e3639dc | ||
|
|
008bacf5d5 | ||
|
|
cc1b056b03 | ||
|
|
3548b4883e | ||
|
|
37a376497c | ||
|
|
83744917b0 | ||
|
|
a548b70e8c | ||
|
|
c8147c046a | ||
|
|
4a7497b451 | ||
|
|
06aa329596 | ||
|
|
9becb0e937 | ||
|
|
7f7765546f | ||
|
|
c7a365b6f1 | ||
|
|
84c125a71b | ||
|
|
06b74591e7 | ||
|
|
6645fbb895 | ||
|
|
c2758da9eb | ||
|
|
7a1c8fef0a | ||
|
|
71c59dddcc | ||
|
|
ef6f90753a | ||
|
|
50fff63252 | ||
|
|
8f5c77c3ce | ||
|
|
88529bc339 | ||
|
|
f37f9d1eda | ||
|
|
836175baab | ||
|
|
7395ac1d4f | ||
|
|
61988fe361 | ||
|
|
533ad8afe9 | ||
|
|
1961f06e08 | ||
|
|
4503e2716e | ||
|
|
e4d81005be | ||
|
|
b6012c4617 | ||
|
|
feee6954a6 | ||
|
|
fea058c53a | ||
|
|
25d97aa136 | ||
|
|
7c8849cc21 | ||
|
|
b362bd672c | ||
|
|
a4f510501c | ||
|
|
e3f6e19950 | ||
|
|
b49b41320e | ||
|
|
6bc3157793 | ||
|
|
dc8a2b17d0 | ||
|
|
c3ae2328af | ||
|
|
57846ea5c0 | ||
|
|
3da88b9b3f | ||
|
|
8130e63e43 | ||
|
|
dc44ebbdaa | ||
|
|
88ad059d54 | ||
|
|
76c076db55 | ||
|
|
5698e6c72a | ||
|
|
e0e4967ad8 | ||
|
|
53c7891599 | ||
|
|
94a17cb74a | ||
|
|
5d139596f8 | ||
|
|
213225418a | ||
|
|
3b3e52097a | ||
|
|
72ceec5680 | ||
|
|
5a220d4e13 | ||
|
|
92e5ab2857 | ||
|
|
64632e3332 | ||
|
|
c0e1f23f23 | ||
|
|
ee8f889cbd | ||
|
|
ffa25aae77 | ||
|
|
04b30a6cc4 | ||
|
|
996a171a4e | ||
|
|
17a271af06 | ||
|
|
f8c366c479 | ||
|
|
934bd2acc7 | ||
|
|
dd0ec84ebe | ||
|
|
e9a372dff5 | ||
|
|
4d7a0d2470 | ||
|
|
c2abe253a1 | ||
|
|
3ddd3115eb | ||
|
|
a3096eab91 | ||
|
|
3fd004b852 | ||
|
|
0a9c7a3257 | ||
|
|
1301390087 |
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2009-2014 Jeremy Ashkenas
|
||||
Copyright (c) 2009-2015 Jeremy Ashkenas
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
|
||||
50
README
50
README
@@ -1,50 +0,0 @@
|
||||
{
|
||||
} } {
|
||||
{ { } }
|
||||
} }{ {
|
||||
{ }{ } } _____ __ __
|
||||
{ }{ }{ { } / ____| / _|/ _|
|
||||
.- { { } { }} -. | | ___ | |_| |_ ___ ___
|
||||
( { } { } { } } ) | | / _ \| _| _/ _ \/ _ \
|
||||
|`-..________ ..-'| | |___| (_) | | | || __/ __/
|
||||
| | \_____\___/|_| |_| \___|\___|
|
||||
| ;--.
|
||||
| (__ \ _____ _ _
|
||||
| | ) ) / ____| (_) | |
|
||||
| |/ / | (___ ___ _ __ _ _ __ | |_
|
||||
| ( / \___ \ / __| '__| | '_ \| __|
|
||||
| |/ ____) | (__| | | | |_) | |_
|
||||
| | |_____/ \___|_| |_| .__/ \__|
|
||||
`-.._________..-' | |
|
||||
|_|
|
||||
|
||||
|
||||
CoffeeScript is a little language that compiles into JavaScript.
|
||||
|
||||
If you have the Node Package Manager installed:
|
||||
npm install -g coffee-script
|
||||
(Leave off the -g if you don't wish to install globally.)
|
||||
|
||||
Or, if you don't wish to use npm:
|
||||
sudo bin/cake install
|
||||
|
||||
Execute a script:
|
||||
coffee /path/to/script.coffee
|
||||
|
||||
Compile a script:
|
||||
coffee -c /path/to/script.coffee
|
||||
|
||||
For documentation, usage, and examples, see:
|
||||
http://coffeescript.org/
|
||||
|
||||
To suggest a feature, report a bug, or general discussion:
|
||||
http://github.com/jashkenas/coffeescript/issues/
|
||||
|
||||
If you'd like to chat, drop by #coffeescript on Freenode IRC,
|
||||
or on webchat.freenode.net.
|
||||
|
||||
The source repository:
|
||||
git://github.com/jashkenas/coffeescript.git
|
||||
|
||||
Top 100 contributors are listed here:
|
||||
http://github.com/jashkenas/coffeescript/contributors
|
||||
@@ -57,4 +57,6 @@ If you'd like to chat, drop by #coffeescript on Freenode IRC.
|
||||
|
||||
The source repository: https://github.com/jashkenas/coffeescript.git
|
||||
|
||||
Changelog: http://coffeescript.org/#changelog
|
||||
|
||||
Our lovely and talented contributors are listed here: http://github.com/jashkenas/coffeescript/contributors
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "coffee-script",
|
||||
"version": "1.9.0",
|
||||
"version": "1.10.0",
|
||||
"main": [
|
||||
"lib/coffee-script/coffee-script.js"
|
||||
],
|
||||
|
||||
24
documentation/coffee/aliases.js
Normal file
24
documentation/coffee/aliases.js
Normal file
@@ -0,0 +1,24 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var volume, winner;
|
||||
|
||||
if (ignition === true) {
|
||||
launch();
|
||||
}
|
||||
|
||||
if (band !== SpinalTap) {
|
||||
volume = 10;
|
||||
}
|
||||
|
||||
if (answer !== false) {
|
||||
letTheWildRumpusBegin();
|
||||
}
|
||||
|
||||
if (car.speed < limit) {
|
||||
accelerate();
|
||||
}
|
||||
|
||||
if (pick === 47 || pick === 92 || pick === 13) {
|
||||
winner = true;
|
||||
}
|
||||
|
||||
print(inspect("My name is " + this.name));
|
||||
24
documentation/coffee/array_comprehensions.js
Normal file
24
documentation/coffee/array_comprehensions.js
Normal file
@@ -0,0 +1,24 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var courses, dish, food, foods, i, j, k, l, len, len1, len2, ref;
|
||||
|
||||
ref = ['toast', 'cheese', 'wine'];
|
||||
for (j = 0, len = ref.length; j < len; j++) {
|
||||
food = ref[j];
|
||||
eat(food);
|
||||
}
|
||||
|
||||
courses = ['greens', 'caviar', 'truffles', 'roast', 'cake'];
|
||||
|
||||
for (i = k = 0, len1 = courses.length; k < len1; i = ++k) {
|
||||
dish = courses[i];
|
||||
menu(i + 1, dish);
|
||||
}
|
||||
|
||||
foods = ['broccoli', 'spinach', 'chocolate'];
|
||||
|
||||
for (l = 0, len2 = foods.length; l < len2; l++) {
|
||||
food = foods[l];
|
||||
if (food !== 'chocolate') {
|
||||
eat(food);
|
||||
}
|
||||
}
|
||||
7
documentation/coffee/block_comment.js
Normal file
7
documentation/coffee/block_comment.js
Normal file
@@ -0,0 +1,7 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
|
||||
/*
|
||||
SkinnyMochaHalfCaffScript Compiler v1.0
|
||||
Released under the MIT License
|
||||
*/
|
||||
|
||||
14
documentation/coffee/cake_tasks.js
Normal file
14
documentation/coffee/cake_tasks.js
Normal file
@@ -0,0 +1,14 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var fs;
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
option('-o', '--output [DIR]', 'directory for compiled code');
|
||||
|
||||
task('build:parser', 'rebuild the Jison parser', function(options) {
|
||||
var code, dir;
|
||||
require('jison');
|
||||
code = require('./lib/grammar').parser.generate();
|
||||
dir = options.output || 'lib';
|
||||
return fs.writeFile(dir + "/parser.js", code);
|
||||
});
|
||||
@@ -4,5 +4,3 @@ $ 'body'
|
||||
.fadeIn 'fast'
|
||||
.addClass '.active'
|
||||
.css 'background', 'white'
|
||||
|
||||
|
||||
|
||||
4
documentation/coffee/chaining.js
Normal file
4
documentation/coffee/chaining.js
Normal file
@@ -0,0 +1,4 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
$('body').click(function(e) {
|
||||
return $('.box').fadeIn('fast').addClass('.active');
|
||||
}).css('background', 'white');
|
||||
@@ -19,7 +19,3 @@ tom = new Horse "Tommy the Palomino"
|
||||
|
||||
sam.move()
|
||||
tom.move()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
57
documentation/coffee/classes.js
Normal file
57
documentation/coffee/classes.js
Normal file
@@ -0,0 +1,57 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var Animal, Horse, Snake, sam, tom,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
Animal = (function() {
|
||||
function Animal(name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
Animal.prototype.move = function(meters) {
|
||||
return alert(this.name + (" moved " + meters + "m."));
|
||||
};
|
||||
|
||||
return Animal;
|
||||
|
||||
})();
|
||||
|
||||
Snake = (function(superClass) {
|
||||
extend(Snake, superClass);
|
||||
|
||||
function Snake() {
|
||||
return Snake.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
Snake.prototype.move = function() {
|
||||
alert("Slithering...");
|
||||
return Snake.__super__.move.call(this, 5);
|
||||
};
|
||||
|
||||
return Snake;
|
||||
|
||||
})(Animal);
|
||||
|
||||
Horse = (function(superClass) {
|
||||
extend(Horse, superClass);
|
||||
|
||||
function Horse() {
|
||||
return Horse.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
Horse.prototype.move = function() {
|
||||
alert("Galloping...");
|
||||
return Horse.__super__.move.call(this, 45);
|
||||
};
|
||||
|
||||
return Horse;
|
||||
|
||||
})(Animal);
|
||||
|
||||
sam = new Snake("Sammy the Python");
|
||||
|
||||
tom = new Horse("Tommy the Palomino");
|
||||
|
||||
sam.move();
|
||||
|
||||
tom.move();
|
||||
@@ -1,5 +1,3 @@
|
||||
cholesterol = 127
|
||||
|
||||
healthy = 200 > cholesterol > 60
|
||||
|
||||
|
||||
|
||||
6
documentation/coffee/comparisons.js
Normal file
6
documentation/coffee/comparisons.js
Normal file
@@ -0,0 +1,6 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var cholesterol, healthy;
|
||||
|
||||
cholesterol = 127;
|
||||
|
||||
healthy = (200 > cholesterol && cholesterol > 60);
|
||||
@@ -7,6 +7,3 @@ else
|
||||
showIt()
|
||||
|
||||
date = if friday then sue else jill
|
||||
|
||||
|
||||
|
||||
|
||||
15
documentation/coffee/conditionals.js
Normal file
15
documentation/coffee/conditionals.js
Normal file
@@ -0,0 +1,15 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var date, mood;
|
||||
|
||||
if (singing) {
|
||||
mood = greatlyImproved;
|
||||
}
|
||||
|
||||
if (happy && knowsIt) {
|
||||
clapsHands();
|
||||
chaChaCha();
|
||||
} else {
|
||||
showIt();
|
||||
}
|
||||
|
||||
date = friday ? sue : jill;
|
||||
@@ -1,6 +1,5 @@
|
||||
class Person
|
||||
constructor: (options) ->
|
||||
{@name, @age, @height} = options
|
||||
|
||||
tim = new Person age: 4
|
||||
constructor: (options) ->
|
||||
{@name, @age, @height = 'average'} = options
|
||||
|
||||
tim = new Person name: 'Tim', age: 4
|
||||
|
||||
17
documentation/coffee/constructor_destructuring.js
Normal file
17
documentation/coffee/constructor_destructuring.js
Normal file
@@ -0,0 +1,17 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var Person, tim;
|
||||
|
||||
Person = (function() {
|
||||
function Person(options) {
|
||||
var ref;
|
||||
this.name = options.name, this.age = options.age, this.height = (ref = options.height) != null ? ref : 'average';
|
||||
}
|
||||
|
||||
return Person;
|
||||
|
||||
})();
|
||||
|
||||
tim = new Person({
|
||||
name: 'Tim',
|
||||
age: 4
|
||||
});
|
||||
@@ -1,8 +1,2 @@
|
||||
fill = (container, liquid = "coffee") ->
|
||||
"Filling the #{container} with #{liquid}..."
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
9
documentation/coffee/default_args.js
Normal file
9
documentation/coffee/default_args.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var fill;
|
||||
|
||||
fill = function(container, liquid) {
|
||||
if (liquid == null) {
|
||||
liquid = "coffee";
|
||||
}
|
||||
return "Filling the " + container + " with " + liquid + "...";
|
||||
};
|
||||
12
documentation/coffee/do.js
Normal file
12
documentation/coffee/do.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var filename, fn, i, len;
|
||||
|
||||
fn = function(filename) {
|
||||
return fs.readFile(filename, function(err, contents) {
|
||||
return compile(filename, contents.toString());
|
||||
});
|
||||
};
|
||||
for (i = 0, len = list.length; i < len; i++) {
|
||||
filename = list[i];
|
||||
fn(filename);
|
||||
}
|
||||
@@ -1,6 +1,3 @@
|
||||
hi = `function() {
|
||||
return [document.title, "Hello JavaScript"].join(": ");
|
||||
}`
|
||||
|
||||
|
||||
|
||||
|
||||
6
documentation/coffee/embedded.js
Normal file
6
documentation/coffee/embedded.js
Normal file
@@ -0,0 +1,6 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var hi;
|
||||
|
||||
hi = function() {
|
||||
return [document.title, "Hello JavaScript"].join(": ");
|
||||
};
|
||||
@@ -4,10 +4,3 @@ speed = 0
|
||||
speed ?= 15
|
||||
|
||||
footprints = yeti ? "bear"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
14
documentation/coffee/existence.js
Normal file
14
documentation/coffee/existence.js
Normal file
@@ -0,0 +1,14 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var footprints, solipsism, speed;
|
||||
|
||||
if ((typeof mind !== "undefined" && mind !== null) && (typeof world === "undefined" || world === null)) {
|
||||
solipsism = true;
|
||||
}
|
||||
|
||||
speed = 0;
|
||||
|
||||
if (speed == null) {
|
||||
speed = 15;
|
||||
}
|
||||
|
||||
footprints = typeof yeti !== "undefined" && yeti !== null ? yeti : "bear";
|
||||
@@ -2,6 +2,3 @@ text = "Every literary critic believes he will
|
||||
outwit history and have the last word"
|
||||
|
||||
[first, ..., last] = text.split " "
|
||||
|
||||
|
||||
|
||||
|
||||
6
documentation/coffee/expansion.js
Normal file
6
documentation/coffee/expansion.js
Normal file
@@ -0,0 +1,6 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var first, last, ref, text;
|
||||
|
||||
text = "Every literary critic believes he will outwit history and have the last word";
|
||||
|
||||
ref = text.split(" "), first = ref[0], last = ref[ref.length - 1];
|
||||
18
documentation/coffee/expressions.js
Normal file
18
documentation/coffee/expressions.js
Normal file
@@ -0,0 +1,18 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var eldest, grade;
|
||||
|
||||
grade = function(student) {
|
||||
if (student.excellentWork) {
|
||||
return "A+";
|
||||
} else if (student.okayStuff) {
|
||||
if (student.triedHard) {
|
||||
return "B";
|
||||
} else {
|
||||
return "B-";
|
||||
}
|
||||
} else {
|
||||
return "C";
|
||||
}
|
||||
};
|
||||
|
||||
eldest = 24 > 21 ? "Liz" : "Ike";
|
||||
@@ -1,3 +1 @@
|
||||
six = (one = 1) + (two = 2) + (three = 3)
|
||||
|
||||
|
||||
|
||||
4
documentation/coffee/expressions_assignment.js
Normal file
4
documentation/coffee/expressions_assignment.js
Normal file
@@ -0,0 +1,4 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var one, six, three, two;
|
||||
|
||||
six = (one = 1) + (two = 2) + (three = 3);
|
||||
11
documentation/coffee/expressions_comprehension.js
Normal file
11
documentation/coffee/expressions_comprehension.js
Normal file
@@ -0,0 +1,11 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var globals, name;
|
||||
|
||||
globals = ((function() {
|
||||
var results;
|
||||
results = [];
|
||||
for (name in window) {
|
||||
results.push(name);
|
||||
}
|
||||
return results;
|
||||
})()).slice(0, 10);
|
||||
@@ -4,4 +4,3 @@ alert(
|
||||
catch error
|
||||
"And the error is ... #{error}"
|
||||
)
|
||||
|
||||
|
||||
12
documentation/coffee/expressions_try.js
Normal file
12
documentation/coffee/expressions_try.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var error;
|
||||
|
||||
alert((function() {
|
||||
var error1;
|
||||
try {
|
||||
return nonexistent / void 0;
|
||||
} catch (error1) {
|
||||
error = error1;
|
||||
return "And the error is ... " + error;
|
||||
}
|
||||
})());
|
||||
@@ -2,5 +2,5 @@ Account = (customer, cart) ->
|
||||
@customer = customer
|
||||
@cart = cart
|
||||
|
||||
$('.shopping_cart').bind 'click', (event) =>
|
||||
$('.shopping_cart').on 'click', (event) =>
|
||||
@customer.purchase @cart
|
||||
12
documentation/coffee/fat_arrow.js
Normal file
12
documentation/coffee/fat_arrow.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var Account;
|
||||
|
||||
Account = function(customer, cart) {
|
||||
this.customer = customer;
|
||||
this.cart = cart;
|
||||
return $('.shopping_cart').on('click', (function(_this) {
|
||||
return function(event) {
|
||||
return _this.customer.purchase(_this.cart);
|
||||
};
|
||||
})(this));
|
||||
};
|
||||
10
documentation/coffee/functions.js
Normal file
10
documentation/coffee/functions.js
Normal file
@@ -0,0 +1,10 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var cube, square;
|
||||
|
||||
square = function(x) {
|
||||
return x * x;
|
||||
};
|
||||
|
||||
cube = function(x) {
|
||||
return square(x) * x;
|
||||
};
|
||||
13
documentation/coffee/generators.js
Normal file
13
documentation/coffee/generators.js
Normal file
@@ -0,0 +1,13 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var perfectSquares;
|
||||
|
||||
perfectSquares = function*() {
|
||||
var num;
|
||||
num = 0;
|
||||
while (true) {
|
||||
num += 1;
|
||||
(yield num * num);
|
||||
}
|
||||
};
|
||||
|
||||
window.ps || (window.ps = perfectSquares());
|
||||
@@ -3,4 +3,3 @@ html = """
|
||||
cup of coffeescript
|
||||
</strong>
|
||||
"""
|
||||
|
||||
|
||||
4
documentation/coffee/heredocs.js
Normal file
4
documentation/coffee/heredocs.js
Normal file
@@ -0,0 +1,4 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var html;
|
||||
|
||||
html = "<strong>\n cup of coffeescript\n</strong>";
|
||||
@@ -7,5 +7,3 @@ OPERATOR = /// ^ (
|
||||
| \?\. # soak access
|
||||
| \.{2,3} # range or splat
|
||||
) ///
|
||||
|
||||
|
||||
|
||||
4
documentation/coffee/heregexes.js
Normal file
4
documentation/coffee/heregexes.js
Normal file
@@ -0,0 +1,4 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var OPERATOR;
|
||||
|
||||
OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?\.|\.{2,3})/;
|
||||
@@ -2,8 +2,3 @@ author = "Wittgenstein"
|
||||
quote = "A picture is a fact. -- #{ author }"
|
||||
|
||||
sentence = "#{ 22 / 7 } is a decent approximation of π"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
8
documentation/coffee/interpolation.js
Normal file
8
documentation/coffee/interpolation.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var author, quote, sentence;
|
||||
|
||||
author = "Wittgenstein";
|
||||
|
||||
quote = "A picture is a fact. -- " + author;
|
||||
|
||||
sentence = (22 / 7) + " is a decent approximation of π";
|
||||
4
documentation/coffee/modulo.coffee
Normal file
4
documentation/coffee/modulo.coffee
Normal file
@@ -0,0 +1,4 @@
|
||||
-7 % 5 == -2 # The remainder of 7 / 5
|
||||
-7 %% 5 == 3 # n %% 5 is always between 0 and 4
|
||||
|
||||
tabs.selectTabAtIndex((tabs.currentIndex - count) %% tabs.length)
|
||||
8
documentation/coffee/modulo.js
Normal file
8
documentation/coffee/modulo.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var modulo = function(a, b) { return (+a % (b = +b) + b) % b; };
|
||||
|
||||
-7 % 5 === -2;
|
||||
|
||||
modulo(-7, 5) === 3;
|
||||
|
||||
tabs.selectTabAtIndex(modulo(tabs.currentIndex - count, tabs.length));
|
||||
@@ -3,7 +3,3 @@ weatherReport = (location) ->
|
||||
[location, 72, "Mostly Sunny"]
|
||||
|
||||
[city, temp, forecast] = weatherReport "Berkeley, CA"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
8
documentation/coffee/multiple_return_values.js
Normal file
8
documentation/coffee/multiple_return_values.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var city, forecast, ref, temp, weatherReport;
|
||||
|
||||
weatherReport = function(location) {
|
||||
return [location, 72, "Mostly Sunny"];
|
||||
};
|
||||
|
||||
ref = weatherReport("Berkeley, CA"), city = ref[0], temp = ref[1], forecast = ref[2];
|
||||
18
documentation/coffee/object_comprehensions.js
Normal file
18
documentation/coffee/object_comprehensions.js
Normal file
@@ -0,0 +1,18 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var age, ages, child, yearsOld;
|
||||
|
||||
yearsOld = {
|
||||
max: 10,
|
||||
ida: 9,
|
||||
tim: 11
|
||||
};
|
||||
|
||||
ages = (function() {
|
||||
var results;
|
||||
results = [];
|
||||
for (child in yearsOld) {
|
||||
age = yearsOld[child];
|
||||
results.push(child + " is " + age);
|
||||
}
|
||||
return results;
|
||||
})();
|
||||
@@ -9,6 +9,3 @@ futurists =
|
||||
]
|
||||
|
||||
{poet: {name, address: [street, city]}} = futurists
|
||||
|
||||
|
||||
|
||||
|
||||
13
documentation/coffee/object_extraction.js
Normal file
13
documentation/coffee/object_extraction.js
Normal file
@@ -0,0 +1,13 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var city, futurists, name, ref, ref1, street;
|
||||
|
||||
futurists = {
|
||||
sculptor: "Umberto Boccioni",
|
||||
painter: "Vladimir Burliuk",
|
||||
poet: {
|
||||
name: "F.T. Marinetti",
|
||||
address: ["Via Roma 42R", "Bellagio, Italy 22021"]
|
||||
}
|
||||
};
|
||||
|
||||
ref = futurists.poet, name = ref.name, (ref1 = ref.address, street = ref1[0], city = ref1[1]);
|
||||
@@ -15,5 +15,3 @@ kids =
|
||||
sister:
|
||||
name: "Ida"
|
||||
age: 9
|
||||
|
||||
|
||||
|
||||
22
documentation/coffee/objects_and_arrays.js
Normal file
22
documentation/coffee/objects_and_arrays.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var bitlist, kids, singers, song;
|
||||
|
||||
song = ["do", "re", "mi", "fa", "so"];
|
||||
|
||||
singers = {
|
||||
Jagger: "Rock",
|
||||
Elvis: "Roll"
|
||||
};
|
||||
|
||||
bitlist = [1, 0, 1, 0, 0, 1, 1, 1, 0];
|
||||
|
||||
kids = {
|
||||
brother: {
|
||||
name: "Max",
|
||||
age: 11
|
||||
},
|
||||
sister: {
|
||||
name: "Ida",
|
||||
age: 9
|
||||
}
|
||||
};
|
||||
@@ -1,5 +1,3 @@
|
||||
$('.account').attr class: 'active'
|
||||
|
||||
log object.class
|
||||
|
||||
|
||||
|
||||
6
documentation/coffee/objects_reserved.js
Normal file
6
documentation/coffee/objects_reserved.js
Normal file
@@ -0,0 +1,6 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
$('.account').attr({
|
||||
"class": 'active'
|
||||
});
|
||||
|
||||
log(object["class"]);
|
||||
45
documentation/coffee/overview.js
Normal file
45
documentation/coffee/overview.js
Normal file
@@ -0,0 +1,45 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var cubes, list, math, num, number, opposite, race, square,
|
||||
slice = [].slice;
|
||||
|
||||
number = 42;
|
||||
|
||||
opposite = true;
|
||||
|
||||
if (opposite) {
|
||||
number = -42;
|
||||
}
|
||||
|
||||
square = function(x) {
|
||||
return x * x;
|
||||
};
|
||||
|
||||
list = [1, 2, 3, 4, 5];
|
||||
|
||||
math = {
|
||||
root: Math.sqrt,
|
||||
square: square,
|
||||
cube: function(x) {
|
||||
return x * square(x);
|
||||
}
|
||||
};
|
||||
|
||||
race = function() {
|
||||
var runners, winner;
|
||||
winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
||||
return print(winner, runners);
|
||||
};
|
||||
|
||||
if (typeof elvis !== "undefined" && elvis !== null) {
|
||||
alert("I knew it!");
|
||||
}
|
||||
|
||||
cubes = (function() {
|
||||
var i, len, results;
|
||||
results = [];
|
||||
for (i = 0, len = list.length; i < len; i++) {
|
||||
num = list[i];
|
||||
results.push(math.cube(num));
|
||||
}
|
||||
return results;
|
||||
})();
|
||||
@@ -2,8 +2,3 @@ theBait = 1000
|
||||
theSwitch = 0
|
||||
|
||||
[theBait, theSwitch] = [theSwitch, theBait]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
8
documentation/coffee/parallel_assignment.js
Normal file
8
documentation/coffee/parallel_assignment.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var ref, theBait, theSwitch;
|
||||
|
||||
theBait = 1000;
|
||||
|
||||
theSwitch = 0;
|
||||
|
||||
ref = [theSwitch, theBait], theBait = ref[0], theSwitch = ref[1];
|
||||
@@ -1,9 +1,3 @@
|
||||
tag = "<impossible>"
|
||||
|
||||
[open, contents..., close] = tag.split("")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
7
documentation/coffee/patterns_and_splats.js
Normal file
7
documentation/coffee/patterns_and_splats.js
Normal file
@@ -0,0 +1,7 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var close, contents, i, open, ref, tag,
|
||||
slice = [].slice;
|
||||
|
||||
tag = "<impossible>";
|
||||
|
||||
ref = tag.split(""), open = ref[0], contents = 3 <= ref.length ? slice.call(ref, 1, i = ref.length - 1) : (i = 1, []), close = ref[i++];
|
||||
@@ -1,3 +1,2 @@
|
||||
String::dasherize = ->
|
||||
this.replace /_/g, "-"
|
||||
|
||||
|
||||
4
documentation/coffee/prototypes.js
vendored
Normal file
4
documentation/coffee/prototypes.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
String.prototype.dasherize = function() {
|
||||
return this.replace(/_/g, "-");
|
||||
};
|
||||
@@ -1,2 +1 @@
|
||||
countdown = (num for num in [10..1])
|
||||
|
||||
|
||||
11
documentation/coffee/range_comprehensions.js
Normal file
11
documentation/coffee/range_comprehensions.js
Normal file
@@ -0,0 +1,11 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var countdown, num;
|
||||
|
||||
countdown = (function() {
|
||||
var i, results;
|
||||
results = [];
|
||||
for (num = i = 10; i >= 1; num = --i) {
|
||||
results.push(num);
|
||||
}
|
||||
return results;
|
||||
})();
|
||||
12
documentation/coffee/scope.js
Normal file
12
documentation/coffee/scope.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var changeNumbers, inner, outer;
|
||||
|
||||
outer = 1;
|
||||
|
||||
changeNumbers = function() {
|
||||
var inner;
|
||||
inner = -1;
|
||||
return outer = 10;
|
||||
};
|
||||
|
||||
inner = changeNumbers();
|
||||
12
documentation/coffee/slices.js
Normal file
12
documentation/coffee/slices.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var copy, end, middle, numbers, start;
|
||||
|
||||
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
|
||||
start = numbers.slice(0, 3);
|
||||
|
||||
middle = numbers.slice(3, -2);
|
||||
|
||||
end = numbers.slice(-2);
|
||||
|
||||
copy = numbers.slice(0);
|
||||
4
documentation/coffee/soaks.js
Normal file
4
documentation/coffee/soaks.js
Normal file
@@ -0,0 +1,4 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var ref, zip;
|
||||
|
||||
zip = typeof lottery.drawWinner === "function" ? (ref = lottery.drawWinner().address) != null ? ref.zipcode : void 0 : void 0;
|
||||
@@ -23,5 +23,3 @@ awardMedals contenders...
|
||||
alert "Gold: " + gold
|
||||
alert "Silver: " + silver
|
||||
alert "The Field: " + rest
|
||||
|
||||
|
||||
|
||||
23
documentation/coffee/splats.js
Normal file
23
documentation/coffee/splats.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var awardMedals, contenders, gold, rest, silver,
|
||||
slice = [].slice;
|
||||
|
||||
gold = silver = rest = "unknown";
|
||||
|
||||
awardMedals = function() {
|
||||
var first, others, second;
|
||||
first = arguments[0], second = arguments[1], others = 3 <= arguments.length ? slice.call(arguments, 2) : [];
|
||||
gold = first;
|
||||
silver = second;
|
||||
return rest = others;
|
||||
};
|
||||
|
||||
contenders = ["Michael Phelps", "Liu Xiang", "Yao Ming", "Allyson Felix", "Shawn Johnson", "Roman Sebrle", "Guo Jingjing", "Tyson Gay", "Asafa Powell", "Usain Bolt"];
|
||||
|
||||
awardMedals.apply(null, contenders);
|
||||
|
||||
alert("Gold: " + gold);
|
||||
|
||||
alert("Silver: " + silver);
|
||||
|
||||
alert("The Field: " + rest);
|
||||
@@ -1,7 +1,3 @@
|
||||
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||
|
||||
numbers[3..6] = [-3, -4, -5, -6]
|
||||
|
||||
|
||||
|
||||
|
||||
6
documentation/coffee/splices.js
Normal file
6
documentation/coffee/splices.js
Normal file
@@ -0,0 +1,6 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var numbers, ref;
|
||||
|
||||
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
|
||||
[].splice.apply(numbers, [3, 4].concat(ref = [-3, -4, -5, -6])), ref;
|
||||
4
documentation/coffee/strings.js
Normal file
4
documentation/coffee/strings.js
Normal file
@@ -0,0 +1,4 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var mobyDick;
|
||||
|
||||
mobyDick = "Call me Ishmael. Some years ago -- never mind how long precisely -- having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world...";
|
||||
24
documentation/coffee/switch.js
Normal file
24
documentation/coffee/switch.js
Normal file
@@ -0,0 +1,24 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
switch (day) {
|
||||
case "Mon":
|
||||
go(work);
|
||||
break;
|
||||
case "Tue":
|
||||
go(relax);
|
||||
break;
|
||||
case "Thu":
|
||||
go(iceFishing);
|
||||
break;
|
||||
case "Fri":
|
||||
case "Sat":
|
||||
if (day === bingoDay) {
|
||||
go(bingo);
|
||||
go(dancing);
|
||||
}
|
||||
break;
|
||||
case "Sun":
|
||||
go(church);
|
||||
break;
|
||||
default:
|
||||
go(work);
|
||||
}
|
||||
19
documentation/coffee/switch_with_no_expression.js
Normal file
19
documentation/coffee/switch_with_no_expression.js
Normal file
@@ -0,0 +1,19 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var grade, score;
|
||||
|
||||
score = 76;
|
||||
|
||||
grade = (function() {
|
||||
switch (false) {
|
||||
case !(score < 60):
|
||||
return 'F';
|
||||
case !(score < 70):
|
||||
return 'D';
|
||||
case !(score < 80):
|
||||
return 'C';
|
||||
case !(score < 90):
|
||||
return 'B';
|
||||
default:
|
||||
return 'A';
|
||||
}
|
||||
})();
|
||||
@@ -5,4 +5,3 @@ catch error
|
||||
print error
|
||||
finally
|
||||
cleanUp()
|
||||
|
||||
|
||||
12
documentation/coffee/try.js
Normal file
12
documentation/coffee/try.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var error, error1;
|
||||
|
||||
try {
|
||||
allHellBreaksLoose();
|
||||
catsAndDogsLivingTogether();
|
||||
} catch (error1) {
|
||||
error = error1;
|
||||
print(error);
|
||||
} finally {
|
||||
cleanUp();
|
||||
}
|
||||
22
documentation/coffee/while.js
Normal file
22
documentation/coffee/while.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var lyrics, num;
|
||||
|
||||
if (this.studyingEconomics) {
|
||||
while (supply > demand) {
|
||||
buy();
|
||||
}
|
||||
while (!(supply > demand)) {
|
||||
sell();
|
||||
}
|
||||
}
|
||||
|
||||
num = 6;
|
||||
|
||||
lyrics = (function() {
|
||||
var results;
|
||||
results = [];
|
||||
while (num -= 1) {
|
||||
results.push(num + " little monkeys, jumping on the bed. One fell out and bumped his head.");
|
||||
}
|
||||
return results;
|
||||
})();
|
||||
@@ -9,6 +9,7 @@ body {
|
||||
width: 950px;
|
||||
margin: 0;
|
||||
padding: 80px 0px 50px 50px;
|
||||
clear: both;
|
||||
}
|
||||
p, li {
|
||||
width: 625px;
|
||||
@@ -56,7 +57,7 @@ table.definitions {
|
||||
text-align: center;
|
||||
padding: 5px 20px;
|
||||
}
|
||||
code, pre, tt, textarea {
|
||||
code, pre, textarea {
|
||||
font-family: Monaco, Consolas, "Lucida Console", monospace;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
@@ -64,7 +65,7 @@ code, pre, tt, textarea {
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
tt {
|
||||
p > code, li > code {
|
||||
display: inline-block;
|
||||
background: #fff;
|
||||
border: 1px solid #dedede;
|
||||
@@ -111,9 +112,12 @@ div.code {
|
||||
float: left;
|
||||
width: 450px;
|
||||
background: #fff;
|
||||
border-left: 1px dotted #d0d0d0;
|
||||
margin: 10px 0 15px 3px;
|
||||
padding: 0 0 0 12px;
|
||||
border: 1px dotted #d0d0d0;
|
||||
border-top-width: 0;
|
||||
border-bottom-width: 0;
|
||||
border-right-width: 0;
|
||||
margin: 0 3px 15px 3px;
|
||||
padding: 10px 0 0 12px;
|
||||
}
|
||||
div.code pre:first-child {
|
||||
border-left: 0;
|
||||
@@ -134,7 +138,6 @@ div.code {
|
||||
height: 50px;
|
||||
min-width: 490px;
|
||||
left: 40px; right: 40px; top: 25px;
|
||||
padding-left: 252px;
|
||||
background: #eee;
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#f8f8f8), to(#dadada));
|
||||
background: -moz-linear-gradient(top, #f8f8f8, #dadada);
|
||||
@@ -149,8 +152,9 @@ div.code {
|
||||
#logo {
|
||||
display: block;
|
||||
outline: none;
|
||||
position: absolute;
|
||||
top: 0px; left: 10px;
|
||||
float: left;
|
||||
width: 242px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
#logo img {
|
||||
margin: 5px 0 0 3px;
|
||||
@@ -221,6 +225,7 @@ div.code {
|
||||
display: block;
|
||||
}
|
||||
.navigation .contents.menu {
|
||||
z-index: 100;
|
||||
border-top: 0;
|
||||
-webkit-border-top-left-radius: 0; -moz-border-radius-topleft: 0; border-top-left-radius: 0;
|
||||
-webkit-border-top-right-radius: 0; -moz-border-radius-topright: 0; border-top-right-radius: 0;
|
||||
@@ -377,3 +382,36 @@ div.code {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
@media (max-width: 820px) {
|
||||
.container {
|
||||
width: auto;
|
||||
padding: 1em;
|
||||
}
|
||||
p, li, table {
|
||||
width: auto;
|
||||
}
|
||||
#fadeout {
|
||||
display: none;
|
||||
}
|
||||
#flybar {
|
||||
position: static;
|
||||
height: auto;
|
||||
min-width: 245px;
|
||||
}
|
||||
#logo {
|
||||
float: none;
|
||||
}
|
||||
.navigation {
|
||||
float: none;
|
||||
border: none;
|
||||
}
|
||||
div.code pre, div.code textarea {
|
||||
border-left: none;
|
||||
border-top-width: 1px;
|
||||
width: auto;
|
||||
float: none;
|
||||
}
|
||||
div.code pre:first-child {
|
||||
border-top: none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ compile = CoffeeScript.compile</pre></div></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>CoffeeScript.e<span class="hljs-function"><span class="hljs-title">val</span> = <span class="hljs-params">(code, options = {})</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre>CoffeeScript.<span class="hljs-function"><span class="hljs-title">eval</span> = <span class="hljs-params">(code, options = {})</span> -></span>
|
||||
options.bare ?= <span class="hljs-literal">on</span>
|
||||
eval compile code, options</pre></div></div>
|
||||
|
||||
@@ -157,7 +157,7 @@ compile = CoffeeScript.compile</pre></div></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>CoffeeScript.r<span class="hljs-function"><span class="hljs-title">un</span> = <span class="hljs-params">(code, options = {})</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre>CoffeeScript.<span class="hljs-function"><span class="hljs-title">run</span> = <span class="hljs-params">(code, options = {})</span> -></span>
|
||||
options.bare = <span class="hljs-literal">on</span>
|
||||
options.shiftLine = <span class="hljs-literal">on</span>
|
||||
Function(compile code, options)()</pre></div></div>
|
||||
@@ -193,7 +193,7 @@ Ported from <a href="https://developer.mozilla.org/en-US/docs/DOM/window.btoa">h
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> btoa? <span class="hljs-keyword">and</span> JSON? <span class="hljs-keyword">and</span> unescape? <span class="hljs-keyword">and</span> encodeURIComponent?
|
||||
<span class="hljs-function"> <span class="hljs-title">compile</span> = <span class="hljs-params">(code, options = {})</span> -></span>
|
||||
<span class="hljs-function"><span class="hljs-title">compile</span> = <span class="hljs-params">(code, options = {})</span> -></span>
|
||||
options.sourceMap = <span class="hljs-literal">true</span>
|
||||
options.inline = <span class="hljs-literal">true</span>
|
||||
{js, v3SourceMap} = CoffeeScript.compile code, options
|
||||
@@ -212,7 +212,7 @@ Ported from <a href="https://developer.mozilla.org/en-US/docs/DOM/window.btoa">h
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>CoffeeScript.l<span class="hljs-function"><span class="hljs-title">oad</span> = <span class="hljs-params">(url, callback, options = {}, hold = <span class="hljs-literal">false</span>)</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre>CoffeeScript.<span class="hljs-function"><span class="hljs-title">load</span> = <span class="hljs-params">(url, callback, options = {}, hold = <span class="hljs-literal">false</span>)</span> -></span>
|
||||
options.sourceFiles = [url]
|
||||
xhr = <span class="hljs-keyword">if</span> <span class="hljs-built_in">window</span>.ActiveXObject
|
||||
<span class="hljs-keyword">new</span> <span class="hljs-built_in">window</span>.ActiveXObject(<span class="hljs-string">'Microsoft.XMLHTTP'</span>)
|
||||
@@ -220,7 +220,7 @@ Ported from <a href="https://developer.mozilla.org/en-US/docs/DOM/window.btoa">h
|
||||
<span class="hljs-keyword">new</span> <span class="hljs-built_in">window</span>.XMLHttpRequest()
|
||||
xhr.open <span class="hljs-string">'GET'</span>, url, <span class="hljs-literal">true</span>
|
||||
xhr.overrideMimeType <span class="hljs-string">'text/plain'</span> <span class="hljs-keyword">if</span> <span class="hljs-string">'overrideMimeType'</span> <span class="hljs-keyword">of</span> xhr
|
||||
xhr.o<span class="hljs-function"><span class="hljs-title">nreadystatechange</span> = -></span>
|
||||
xhr.<span class="hljs-function"><span class="hljs-title">onreadystatechange</span> = -></span>
|
||||
<span class="hljs-keyword">if</span> xhr.readyState <span class="hljs-keyword">is</span> <span class="hljs-number">4</span>
|
||||
<span class="hljs-keyword">if</span> xhr.status <span class="hljs-keyword">in</span> [<span class="hljs-number">0</span>, <span class="hljs-number">200</span>]
|
||||
param = [xhr.responseText, options]
|
||||
@@ -250,8 +250,8 @@ This happens on page load.</p>
|
||||
coffeetypes = [<span class="hljs-string">'text/coffeescript'</span>, <span class="hljs-string">'text/literate-coffeescript'</span>]
|
||||
coffees = (s <span class="hljs-keyword">for</span> s <span class="hljs-keyword">in</span> scripts <span class="hljs-keyword">when</span> s.type <span class="hljs-keyword">in</span> coffeetypes)
|
||||
index = <span class="hljs-number">0</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">execute</span> = -></span>
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">execute</span> = -></span>
|
||||
param = coffees[index]
|
||||
<span class="hljs-keyword">if</span> param <span class="hljs-keyword">instanceof</span> Array
|
||||
CoffeeScript.run param...
|
||||
@@ -261,9 +261,10 @@ This happens on page load.</p>
|
||||
<span class="hljs-keyword">for</span> script, i <span class="hljs-keyword">in</span> coffees
|
||||
<span class="hljs-keyword">do</span> <span class="hljs-function"><span class="hljs-params">(script, i)</span> -></span>
|
||||
options = <span class="hljs-attribute">literate</span>: script.type <span class="hljs-keyword">is</span> coffeetypes[<span class="hljs-number">1</span>]
|
||||
<span class="hljs-keyword">if</span> script.src
|
||||
CoffeeScript.load script.src,
|
||||
<span class="hljs-function"> <span class="hljs-params">(param)</span> -></span>
|
||||
source = script.src <span class="hljs-keyword">or</span> script.getAttribute(<span class="hljs-string">'data-src'</span>)
|
||||
<span class="hljs-keyword">if</span> source
|
||||
CoffeeScript.load source,
|
||||
<span class="hljs-function"><span class="hljs-params">(param)</span> -></span>
|
||||
coffees[i] = param
|
||||
execute()
|
||||
options
|
||||
|
||||
@@ -260,7 +260,7 @@ original directory name, when running Cake tasks from subdirectories.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.r<span class="hljs-function"><span class="hljs-title">un</span> = -></span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">run</span> = -></span>
|
||||
<span class="hljs-built_in">global</span>.__originalDirname = fs.realpathSync <span class="hljs-string">'.'</span>
|
||||
process.chdir cakefileDirectory __originalDirname
|
||||
args = process.argv[<span class="hljs-number">2.</span>.]
|
||||
@@ -314,8 +314,8 @@ original directory name, when running Cake tasks from subdirectories.</p>
|
||||
<span class="hljs-built_in">console</span>.error message + <span class="hljs-string">'\n'</span>
|
||||
<span class="hljs-built_in">console</span>.log <span class="hljs-string">'To see a list of all tasks/options, run "cake"'</span>
|
||||
process.exit <span class="hljs-number">1</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">missingTask</span> = <span class="hljs-params">(task)</span> -></span> fatalError <span class="hljs-string">"No such task: <span class="hljs-subst">#{task}</span>"</span></pre></div></div>
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">missingTask</span> = <span class="hljs-params">(task)</span> -></span> fatalError <span class="hljs-string">"No such task: <span class="hljs-subst">#{task}</span>"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
@@ -144,9 +144,9 @@ SourceMap = <span class="hljs-built_in">require</span> <span class="hljs-str
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.VERSION = <span class="hljs-string">'1.9.0'</span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.VERSION = <span class="hljs-string">'1.10.0'</span>
|
||||
|
||||
exports.FILE_EXTENSIONS = [<span class="hljs-string">'.coffee'</span>, <span class="hljs-string">'.litcoffee'</span>, <span class="hljs-string">'.coffee.md'</span>]</pre></div></div>
|
||||
<span class="hljs-built_in">exports</span>.FILE_EXTENSIONS = [<span class="hljs-string">'.coffee'</span>, <span class="hljs-string">'.litcoffee'</span>, <span class="hljs-string">'.coffee.md'</span>]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -161,7 +161,7 @@ exports.FILE_EXTENSIONS = [<span class="hljs-string">'.coffee'</span>, <span cla
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.helpers = helpers</pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.helpers = helpers</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -178,10 +178,11 @@ lexer/parser/compiler.</p>
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">withPrettyErrors</span> = <span class="hljs-params">(fn)</span> -></span>
|
||||
<span class="hljs-function"> <span class="hljs-params">(code, options = {})</span> -></span>
|
||||
<span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -></span>
|
||||
<span class="hljs-keyword">try</span>
|
||||
fn.call @, code, options
|
||||
<span class="hljs-keyword">catch</span> err
|
||||
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">'string'</span> <span class="hljs-comment"># Support `CoffeeScript.nodes(tokens)`.</span>
|
||||
<span class="hljs-keyword">throw</span> helpers.updateSyntaxError err, code, options.filename</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -203,7 +204,7 @@ lookups.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.compile = compile = withPrettyErrors <span class="hljs-function"><span class="hljs-params">(code, options)</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.compile = compile = withPrettyErrors <span class="hljs-function"><span class="hljs-params">(code, options)</span> -></span>
|
||||
{merge, extend} = helpers
|
||||
options = extend {}, options
|
||||
|
||||
@@ -222,14 +223,12 @@ lookups.</p>
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>Pass a list of referenced variables, so that generated variables won’t get
|
||||
the same name. Since all generated variables start with an underscore only
|
||||
referenced variables also starting with an underscore are passed, as an
|
||||
optimization.</p>
|
||||
the same name.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> options.referencedVars = (
|
||||
token[<span class="hljs-number">1</span>] <span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens <span class="hljs-keyword">when</span> token.variable <span class="hljs-keyword">and</span> token[<span class="hljs-number">1</span>].charAt(<span class="hljs-number">0</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'_'</span>
|
||||
token[<span class="hljs-number">1</span>] <span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens <span class="hljs-keyword">when</span> token.variable
|
||||
)
|
||||
|
||||
fragments = parser.parse(tokens).compileToFragments options
|
||||
@@ -254,8 +253,22 @@ optimization.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> options.sourceMap
|
||||
<span class="hljs-keyword">if</span> fragment.locationData
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> options.sourceMap</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Do not include empty, whitespace, or semicolon-only fragments.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> fragment.locationData <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> <span class="hljs-regexp">/^[;\s]*$/</span>.test fragment.code
|
||||
map.add(
|
||||
[fragment.locationData.first_line, fragment.locationData.first_column]
|
||||
[currentLine, currentColumn]
|
||||
@@ -270,11 +283,11 @@ optimization.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>Copy the code from each fragment into the final JavaScript.</p>
|
||||
|
||||
@@ -297,39 +310,18 @@ optimization.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>Tokenize a string of CoffeeScript code, and return the array of tokens.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.tokens = withPrettyErrors <span class="hljs-function"><span class="hljs-params">(code, options)</span> -></span>
|
||||
lexer.tokenize code, options</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>Parse a string of CoffeeScript code or an array of lexed tokens, and
|
||||
return the AST. You can then compile it by calling <code>.compile()</code> on the root,
|
||||
or traverse it by using <code>.traverseChildren()</code> with a callback.</p>
|
||||
<p>Tokenize a string of CoffeeScript code, and return the array of tokens.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.nodes = withPrettyErrors <span class="hljs-function"><span class="hljs-params">(source, options)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> source <span class="hljs-keyword">is</span> <span class="hljs-string">'string'</span>
|
||||
parser.parse lexer.tokenize source, options
|
||||
<span class="hljs-keyword">else</span>
|
||||
parser.parse source</pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.tokens = withPrettyErrors <span class="hljs-function"><span class="hljs-params">(code, options)</span> -></span>
|
||||
lexer.tokenize code, options</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -340,13 +332,17 @@ or traverse it by using <code>.traverseChildren()</code> with a callback.</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>Compile and execute a string of CoffeeScript (on the server), correctly
|
||||
setting <code>__filename</code>, <code>__dirname</code>, and relative <code>require()</code>.</p>
|
||||
<p>Parse a string of CoffeeScript code or an array of lexed tokens, and
|
||||
return the AST. You can then compile it by calling <code>.compile()</code> on the root,
|
||||
or traverse it by using <code>.traverseChildren()</code> with a callback.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.r<span class="hljs-function"><span class="hljs-title">un</span> = <span class="hljs-params">(code, options = {})</span> -></span>
|
||||
mainModule = <span class="hljs-built_in">require</span>.main</pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.nodes = withPrettyErrors <span class="hljs-function"><span class="hljs-params">(source, options)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> source <span class="hljs-keyword">is</span> <span class="hljs-string">'string'</span>
|
||||
parser.parse lexer.tokenize source, options
|
||||
<span class="hljs-keyword">else</span>
|
||||
parser.parse source</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -357,6 +353,23 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>Compile and execute a string of CoffeeScript (on the server), correctly
|
||||
setting <code>__filename</code>, <code>__dirname</code>, and relative <code>require()</code>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">run</span> = <span class="hljs-params">(code, options = {})</span> -></span>
|
||||
mainModule = <span class="hljs-built_in">require</span>.main</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-13">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
</div>
|
||||
<p>Set the filename.</p>
|
||||
|
||||
</div>
|
||||
@@ -367,11 +380,11 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-13">
|
||||
<li id="section-14">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
</div>
|
||||
<p>Clear the module cache.</p>
|
||||
|
||||
@@ -382,11 +395,11 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-14">
|
||||
<li id="section-15">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
</div>
|
||||
<p>Assign paths for node_modules loading</p>
|
||||
|
||||
@@ -401,11 +414,11 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-15">
|
||||
<li id="section-16">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
</div>
|
||||
<p>Compile.</p>
|
||||
|
||||
@@ -420,18 +433,18 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-16">
|
||||
<li id="section-17">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
</div>
|
||||
<p>Compile and evaluate a string of CoffeeScript (in a Node.js-like environment).
|
||||
The CoffeeScript REPL uses this to run the input.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.e<span class="hljs-function"><span class="hljs-title">val</span> = <span class="hljs-params">(code, options = {})</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">eval</span> = <span class="hljs-params">(code, options = {})</span> -></span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> code = code.trim()
|
||||
createContext = vm.Script.createContext ? vm.createContext
|
||||
|
||||
@@ -454,11 +467,11 @@ The CoffeeScript REPL uses this to run the input.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-17">
|
||||
<li id="section-18">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
</div>
|
||||
<p>define module/require only if they chose not to specify their own</p>
|
||||
|
||||
@@ -467,35 +480,10 @@ The CoffeeScript REPL uses this to run the input.</p>
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> sandbox <span class="hljs-keyword">isnt</span> <span class="hljs-built_in">global</span> <span class="hljs-keyword">or</span> sandbox.<span class="hljs-built_in">module</span> <span class="hljs-keyword">or</span> sandbox.<span class="hljs-built_in">require</span>
|
||||
Module = <span class="hljs-built_in">require</span> <span class="hljs-string">'module'</span>
|
||||
sandbox.<span class="hljs-built_in">module</span> = _module = <span class="hljs-keyword">new</span> Module(options.modulename || <span class="hljs-string">'eval'</span>)
|
||||
sandbox.<span class="hljs-built_in">require</span> = _<span class="hljs-function"><span class="hljs-title">require</span> = <span class="hljs-params">(path)</span> -></span> Module._load path, _module, <span class="hljs-literal">true</span>
|
||||
sandbox.<span class="hljs-built_in">require</span> = <span class="hljs-function"><span class="hljs-title">_require</span> = <span class="hljs-params">(path)</span> -></span> Module._load path, _module, <span class="hljs-literal">true</span>
|
||||
_module.filename = sandbox.__filename
|
||||
_require[r] = <span class="hljs-built_in">require</span>[r] <span class="hljs-keyword">for</span> r <span class="hljs-keyword">in</span> Object.getOwnPropertyNames <span class="hljs-built_in">require</span> <span class="hljs-keyword">when</span> r <span class="hljs-keyword">isnt</span> <span class="hljs-string">'paths'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-18">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
</div>
|
||||
<p>use the same hack node currently uses for their own REPL</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> _require.paths = _module.paths = Module._nodeModulePaths process.cwd()
|
||||
_require.r<span class="hljs-function"><span class="hljs-title">esolve</span> = <span class="hljs-params">(request)</span> -></span> Module._resolveFilename request, _module
|
||||
o = {}
|
||||
o[k] = v <span class="hljs-keyword">for</span> own k, v <span class="hljs-keyword">of</span> options
|
||||
o.bare = <span class="hljs-literal">on</span> <span class="hljs-comment"># ensure return value</span>
|
||||
js = compile code, o
|
||||
<span class="hljs-keyword">if</span> sandbox <span class="hljs-keyword">is</span> <span class="hljs-built_in">global</span>
|
||||
vm.runInThisContext js
|
||||
<span class="hljs-keyword">else</span>
|
||||
vm.runInContext js, sandbox
|
||||
|
||||
exports.r<span class="hljs-function"><span class="hljs-title">egister</span> = -></span> <span class="hljs-built_in">require</span> <span class="hljs-string">'./register'</span></pre></div></div>
|
||||
<span class="hljs-keyword">for</span> r <span class="hljs-keyword">in</span> Object.getOwnPropertyNames <span class="hljs-built_in">require</span> <span class="hljs-keyword">when</span> r <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> [<span class="hljs-string">'paths'</span>, <span class="hljs-string">'arguments'</span>, <span class="hljs-string">'caller'</span>]
|
||||
_require[r] = <span class="hljs-built_in">require</span>[r]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -506,6 +494,32 @@ exports.r<span class="hljs-function"><span class="hljs-title">egister</span> = -
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
</div>
|
||||
<p>use the same hack node currently uses for their own REPL</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> _require.paths = _module.paths = Module._nodeModulePaths process.cwd()
|
||||
_require.<span class="hljs-function"><span class="hljs-title">resolve</span> = <span class="hljs-params">(request)</span> -></span> Module._resolveFilename request, _module
|
||||
o = {}
|
||||
o[k] = v <span class="hljs-keyword">for</span> own k, v <span class="hljs-keyword">of</span> options
|
||||
o.bare = <span class="hljs-literal">on</span> <span class="hljs-comment"># ensure return value</span>
|
||||
js = compile code, o
|
||||
<span class="hljs-keyword">if</span> sandbox <span class="hljs-keyword">is</span> <span class="hljs-built_in">global</span>
|
||||
vm.runInThisContext js
|
||||
<span class="hljs-keyword">else</span>
|
||||
vm.runInContext js, sandbox
|
||||
|
||||
<span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">register</span> = -></span> <span class="hljs-built_in">require</span> <span class="hljs-string">'./register'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-20">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
</div>
|
||||
<p>Throw error with deprecation warning when depending upon implicit <code>require.extensions</code> registration</p>
|
||||
|
||||
</div>
|
||||
@@ -517,7 +531,7 @@ exports.r<span class="hljs-function"><span class="hljs-title">egister</span> = -
|
||||
Use CoffeeScript.register() or require the coffee-script/register module to require <span class="hljs-subst">#{ext}</span> files.
|
||||
"""</span>
|
||||
|
||||
exports._<span class="hljs-function"><span class="hljs-title">compileFile</span> = <span class="hljs-params">(filename, sourceMap = <span class="hljs-literal">no</span>)</span> -></span>
|
||||
<span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">_compileFile</span> = <span class="hljs-params">(filename, sourceMap = <span class="hljs-literal">no</span>)</span> -></span>
|
||||
raw = fs.readFileSync filename, <span class="hljs-string">'utf8'</span>
|
||||
stripped = <span class="hljs-keyword">if</span> raw.charCodeAt(<span class="hljs-number">0</span>) <span class="hljs-keyword">is</span> <span class="hljs-number">0xFEFF</span> <span class="hljs-keyword">then</span> raw.substring <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> raw
|
||||
|
||||
@@ -528,11 +542,11 @@ exports._<span class="hljs-function"><span class="hljs-title">compileFile</span>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-20">
|
||||
<li id="section-21">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
</div>
|
||||
<p>As the filename and code of a dynamically loaded file will be different
|
||||
from the original file compiled with CoffeeScript.run, add that
|
||||
@@ -547,11 +561,11 @@ information to error so it can be pretty-printed later.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-21">
|
||||
<li id="section-22">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
</div>
|
||||
<p>Instantiate a Lexer for our use here.</p>
|
||||
|
||||
@@ -562,11 +576,11 @@ information to error so it can be pretty-printed later.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-22">
|
||||
<li id="section-23">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
</div>
|
||||
<p>The real Lexer produces a generic stream of tokens. This object provides a
|
||||
thin wrapper around it, compatible with the Jison API. We can then pass it
|
||||
@@ -594,11 +608,11 @@ directly as a “Jison lexer”.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-23">
|
||||
<li id="section-24">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
</div>
|
||||
<p>Make all the AST nodes visible to the parser.</p>
|
||||
|
||||
@@ -609,27 +623,27 @@ directly as a “Jison lexer”.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-24">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
</div>
|
||||
<p>Override Jison’s default error handling function.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>parser.yy.p<span class="hljs-function"><span class="hljs-title">arseError</span> = <span class="hljs-params">(message, {token})</span> -></span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-25">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-25">¶</a>
|
||||
</div>
|
||||
<p>Override Jison’s default error handling function.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>parser.yy.<span class="hljs-function"><span class="hljs-title">parseError</span> = <span class="hljs-params">(message, {token})</span> -></span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-26">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-26">¶</a>
|
||||
</div>
|
||||
<p>Disregard Jison’s message, it contains redundant line numer information.
|
||||
Disregard the token, we take its value directly from the lexer in case
|
||||
the error is caused by a generated token which might refer to its origin.</p>
|
||||
@@ -639,21 +653,24 @@ the error is caused by a generated token which might refer to its origin.</p>
|
||||
<div class="content"><div class='highlight'><pre> {errorToken, tokens} = parser
|
||||
[errorTag, errorText, errorLoc] = errorToken
|
||||
|
||||
errorText = <span class="hljs-keyword">if</span> errorToken <span class="hljs-keyword">is</span> tokens[tokens.length - <span class="hljs-number">1</span>]
|
||||
<span class="hljs-string">'end of input'</span>
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> errorTag <span class="hljs-keyword">in</span> [<span class="hljs-string">'INDENT'</span>, <span class="hljs-string">'OUTDENT'</span>]
|
||||
<span class="hljs-string">'indentation'</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
helpers.nameWhitespaceCharacter errorText</pre></div></div>
|
||||
errorText = <span class="hljs-keyword">switch</span>
|
||||
<span class="hljs-keyword">when</span> errorToken <span class="hljs-keyword">is</span> tokens[tokens.length - <span class="hljs-number">1</span>]
|
||||
<span class="hljs-string">'end of input'</span>
|
||||
<span class="hljs-keyword">when</span> errorTag <span class="hljs-keyword">in</span> [<span class="hljs-string">'INDENT'</span>, <span class="hljs-string">'OUTDENT'</span>]
|
||||
<span class="hljs-string">'indentation'</span>
|
||||
<span class="hljs-keyword">when</span> errorTag <span class="hljs-keyword">in</span> [<span class="hljs-string">'IDENTIFIER'</span>, <span class="hljs-string">'NUMBER'</span>, <span class="hljs-string">'STRING'</span>, <span class="hljs-string">'STRING_START'</span>, <span class="hljs-string">'REGEX'</span>, <span class="hljs-string">'REGEX_START'</span>]
|
||||
errorTag.replace(<span class="hljs-regexp">/_START$/</span>, <span class="hljs-string">''</span>).toLowerCase()
|
||||
<span class="hljs-keyword">else</span>
|
||||
helpers.nameWhitespaceCharacter errorText</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-26">
|
||||
<li id="section-27">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-26">¶</a>
|
||||
<a class="pilcrow" href="#section-27">¶</a>
|
||||
</div>
|
||||
<p>The second argument has a <code>loc</code> property, which should have the location
|
||||
data for this token. Unfortunately, Jison seems to send an outdated <code>loc</code>
|
||||
@@ -667,11 +684,11 @@ from the lexer.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-27">
|
||||
<li id="section-28">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-27">¶</a>
|
||||
<a class="pilcrow" href="#section-28">¶</a>
|
||||
</div>
|
||||
<p>Based on <a href="http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js">http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js</a>
|
||||
Modified to handle sourceMap</p>
|
||||
@@ -699,11 +716,11 @@ Modified to handle sourceMap</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-28">
|
||||
<li id="section-29">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-28">¶</a>
|
||||
<a class="pilcrow" href="#section-29">¶</a>
|
||||
</div>
|
||||
<p>Check for a sourceMap position</p>
|
||||
|
||||
@@ -744,11 +761,11 @@ Modified to handle sourceMap</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-29">
|
||||
<li id="section-30">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-29">¶</a>
|
||||
<a class="pilcrow" href="#section-30">¶</a>
|
||||
</div>
|
||||
<p>Map of filenames -> sourceMap object.</p>
|
||||
|
||||
@@ -759,11 +776,11 @@ Modified to handle sourceMap</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-30">
|
||||
<li id="section-31">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-30">¶</a>
|
||||
<a class="pilcrow" href="#section-31">¶</a>
|
||||
</div>
|
||||
<p>Generates the source map for a coffee file and stores it in the local cache variable.</p>
|
||||
|
||||
@@ -771,18 +788,18 @@ Modified to handle sourceMap</p>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">getSourceMap</span> = <span class="hljs-params">(filename)</span> -></span>
|
||||
<span class="hljs-keyword">return</span> sourceMaps[filename] <span class="hljs-keyword">if</span> sourceMaps[filename]
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> path?.extname(filename) <span class="hljs-keyword">in</span> exports.FILE_EXTENSIONS
|
||||
answer = exports._compileFile filename, <span class="hljs-literal">true</span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> path?.extname(filename) <span class="hljs-keyword">in</span> <span class="hljs-built_in">exports</span>.FILE_EXTENSIONS
|
||||
answer = <span class="hljs-built_in">exports</span>._compileFile filename, <span class="hljs-literal">true</span>
|
||||
sourceMaps[filename] = answer.sourceMap</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-31">
|
||||
<li id="section-32">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-31">¶</a>
|
||||
<a class="pilcrow" href="#section-32">¶</a>
|
||||
</div>
|
||||
<p>Based on <a href="http://goo.gl/ZTx1p">michaelficarra/CoffeeScriptRedux</a>
|
||||
NodeJS / V8 have no support for transforming positions in stack traces using
|
||||
@@ -791,14 +808,14 @@ positions.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>Error.p<span class="hljs-function"><span class="hljs-title">repareStackTrace</span> = <span class="hljs-params">(err, stack)</span> -></span>
|
||||
<span class="hljs-function"> <span class="hljs-title">getSourceMapping</span> = <span class="hljs-params">(filename, line, column)</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre>Error.<span class="hljs-function"><span class="hljs-title">prepareStackTrace</span> = <span class="hljs-params">(err, stack)</span> -></span>
|
||||
<span class="hljs-function"><span class="hljs-title">getSourceMapping</span> = <span class="hljs-params">(filename, line, column)</span> -></span>
|
||||
sourceMap = getSourceMap filename
|
||||
answer = sourceMap.sourceLocation [line - <span class="hljs-number">1</span>, column - <span class="hljs-number">1</span>] <span class="hljs-keyword">if</span> sourceMap
|
||||
<span class="hljs-keyword">if</span> answer <span class="hljs-keyword">then</span> [answer[<span class="hljs-number">0</span>] + <span class="hljs-number">1</span>, answer[<span class="hljs-number">1</span>] + <span class="hljs-number">1</span>] <span class="hljs-keyword">else</span> <span class="hljs-literal">null</span>
|
||||
|
||||
frames = <span class="hljs-keyword">for</span> frame <span class="hljs-keyword">in</span> stack
|
||||
<span class="hljs-keyword">break</span> <span class="hljs-keyword">if</span> frame.getFunction() <span class="hljs-keyword">is</span> exports.run
|
||||
<span class="hljs-keyword">break</span> <span class="hljs-keyword">if</span> frame.getFunction() <span class="hljs-keyword">is</span> <span class="hljs-built_in">exports</span>.run
|
||||
<span class="hljs-string">" at <span class="hljs-subst">#{formatSourcePosition frame, getSourceMapping}</span>"</span>
|
||||
|
||||
<span class="hljs-string">"<span class="hljs-subst">#{err.toString()}</span>\n<span class="hljs-subst">#{frames.join <span class="hljs-string">'\n'</span>}</span>\n"</span></pre></div></div>
|
||||
|
||||
@@ -160,11 +160,11 @@ useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>helpers.extend CoffeeScript, <span class="hljs-keyword">new</span> EventEmitter
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">printLine</span> = <span class="hljs-params">(line)</span> -></span> process.stdout.write line + <span class="hljs-string">'\n'</span>
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">printLine</span> = <span class="hljs-params">(line)</span> -></span> process.stdout.write line + <span class="hljs-string">'\n'</span>
|
||||
<span class="hljs-function"><span class="hljs-title">printWarn</span> = <span class="hljs-params">(line)</span> -></span> process.stderr.write line + <span class="hljs-string">'\n'</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">hidden</span> = <span class="hljs-params">(file)</span> -></span> <span class="hljs-regexp">/^\.|~$/</span>.test file</pre></div></div>
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">hidden</span> = <span class="hljs-params">(file)</span> -></span> <span class="hljs-regexp">/^\.|~$/</span>.test file</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -211,6 +211,7 @@ useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs
|
||||
[ <span class="hljs-string">'--no-header'</span>, <span class="hljs-string">'suppress the "Generated by" header'</span>]
|
||||
[<span class="hljs-string">'-o'</span>, <span class="hljs-string">'--output [DIR]'</span>, <span class="hljs-string">'set the output directory for compiled JavaScript'</span>]
|
||||
[<span class="hljs-string">'-p'</span>, <span class="hljs-string">'--print'</span>, <span class="hljs-string">'print out the compiled JavaScript'</span>]
|
||||
[<span class="hljs-string">'-r'</span>, <span class="hljs-string">'--require [MODULE*]'</span>, <span class="hljs-string">'require the given module before eval or REPL'</span>]
|
||||
[<span class="hljs-string">'-s'</span>, <span class="hljs-string">'--stdio'</span>, <span class="hljs-string">'listen for and compile scripts over stdio'</span>]
|
||||
[<span class="hljs-string">'-l'</span>, <span class="hljs-string">'--literate'</span>, <span class="hljs-string">'treat stdio as literate style coffee-script'</span>]
|
||||
[<span class="hljs-string">'-t'</span>, <span class="hljs-string">'--tokens'</span>, <span class="hljs-string">'print out the tokens that the lexer/rewriter produce'</span>]
|
||||
@@ -253,7 +254,7 @@ Many flags cause us to divert before compiling anything. Flags passed after
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.r<span class="hljs-function"><span class="hljs-title">un</span> = -></span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">run</span> = -></span>
|
||||
parseOptions()</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -272,6 +273,8 @@ Many flags cause us to divert before compiling anything. Flags passed after
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> replCliOpts = <span class="hljs-attribute">useGlobal</span>: <span class="hljs-literal">yes</span>
|
||||
opts.prelude = makePrelude opts.<span class="hljs-built_in">require</span> <span class="hljs-keyword">if</span> opts.<span class="hljs-built_in">require</span>
|
||||
replCliOpts.prelude = opts.prelude
|
||||
<span class="hljs-keyword">return</span> forkNode() <span class="hljs-keyword">if</span> opts.nodejs
|
||||
<span class="hljs-keyword">return</span> usage() <span class="hljs-keyword">if</span> opts.help
|
||||
<span class="hljs-keyword">return</span> version() <span class="hljs-keyword">if</span> opts.version
|
||||
@@ -302,7 +305,14 @@ Many flags cause us to divert before compiling anything. Flags passed after
|
||||
'''</span>
|
||||
<span class="hljs-keyword">for</span> source <span class="hljs-keyword">in</span> opts.arguments
|
||||
source = path.resolve source
|
||||
compilePath source, <span class="hljs-literal">yes</span>, source</pre></div></div>
|
||||
compilePath source, <span class="hljs-literal">yes</span>, source
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">makePrelude</span> = <span class="hljs-params">(requires)</span> -></span>
|
||||
requires.map <span class="hljs-function"><span class="hljs-params">(<span class="hljs-built_in">module</span>)</span> -></span>
|
||||
[_, name, <span class="hljs-built_in">module</span>] = match <span class="hljs-keyword">if</span> match = <span class="hljs-built_in">module</span>.match(<span class="hljs-regexp">/^(.*)=(.*)$/</span>)
|
||||
name ||= helpers.baseFileName <span class="hljs-built_in">module</span>, <span class="hljs-literal">yes</span>, useWinPathSep
|
||||
<span class="hljs-string">"<span class="hljs-subst">#{name}</span> = require('<span class="hljs-subst">#{<span class="hljs-built_in">module</span>}</span>')"</span>
|
||||
.join <span class="hljs-string">';'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -356,8 +366,8 @@ extension source files in it and all subdirectories.</p>
|
||||
compileScript(source, code.toString(), base)
|
||||
<span class="hljs-keyword">else</span>
|
||||
notSources[source] = <span class="hljs-literal">yes</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">findDirectoryIndex</span> = <span class="hljs-params">(source)</span> -></span>
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">findDirectoryIndex</span> = <span class="hljs-params">(source)</span> -></span>
|
||||
<span class="hljs-keyword">for</span> ext <span class="hljs-keyword">in</span> CoffeeScript.FILE_EXTENSIONS
|
||||
index = path.join source, <span class="hljs-string">"index<span class="hljs-subst">#{ext}</span>"</span>
|
||||
<span class="hljs-keyword">try</span>
|
||||
@@ -394,6 +404,7 @@ requested options. If evaluating the script directly sets <code>__filename</code
|
||||
printLine CoffeeScript.nodes(t.input, t.options).toString().trim()
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> o.run
|
||||
CoffeeScript.register()
|
||||
CoffeeScript.eval opts.prelude, t.options <span class="hljs-keyword">if</span> opts.prelude
|
||||
CoffeeScript.run t.input, t.options
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> o.join <span class="hljs-keyword">and</span> t.file <span class="hljs-keyword">isnt</span> o.join
|
||||
t.input = helpers.invertLiterate t.input <span class="hljs-keyword">if</span> helpers.isLiterate file
|
||||
@@ -460,9 +471,9 @@ them together.</p>
|
||||
<div class="content"><div class='highlight'><pre>joinTimeout = <span class="hljs-literal">null</span>
|
||||
<span class="hljs-function"><span class="hljs-title">compileJoin</span> = -></span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> opts.join
|
||||
<span class="hljs-keyword">unless</span> sourceCode.some(<span class="hljs-function"><span class="hljs-params">(code)</span> -></span> code <span class="hljs-keyword">is</span> <span class="hljs-literal">null</span>)
|
||||
clearTimeout joinTimeout
|
||||
joinTimeout = wait <span class="hljs-number">100</span>,<span class="hljs-function"> -></span>
|
||||
<span class="hljs-keyword">unless</span> sourceCode.some<span class="hljs-function"><span class="hljs-params">((code) -> code <span class="hljs-keyword">is</span> <span class="hljs-literal">null</span>)</span>
|
||||
<span class="hljs-title">clearTimeout</span> <span class="hljs-title">joinTimeout</span>
|
||||
<span class="hljs-title">joinTimeout</span> = <span class="hljs-title">wait</span> 100, -></span>
|
||||
compileScript opts.join, sourceCode.join(<span class="hljs-string">'\n'</span>), opts.join</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -484,8 +495,8 @@ such as <code>--print</code>.</p>
|
||||
watcher = <span class="hljs-literal">null</span>
|
||||
prevStats = <span class="hljs-literal">null</span>
|
||||
compileTimeout = <span class="hljs-literal">null</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">watchErr</span> = <span class="hljs-params">(err)</span> -></span>
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">watchErr</span> = <span class="hljs-params">(err)</span> -></span>
|
||||
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> source <span class="hljs-keyword">in</span> sources
|
||||
<span class="hljs-keyword">try</span>
|
||||
@@ -494,8 +505,8 @@ such as <code>--print</code>.</p>
|
||||
<span class="hljs-keyword">catch</span>
|
||||
removeSource source, base
|
||||
compileJoin()
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">compile</span> = -></span>
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">compile</span> = -></span>
|
||||
clearTimeout compileTimeout
|
||||
compileTimeout = wait <span class="hljs-number">25</span>,<span class="hljs-function"> -></span>
|
||||
fs.stat source, <span class="hljs-function"><span class="hljs-params">(err, stats)</span> -></span>
|
||||
@@ -508,15 +519,15 @@ such as <code>--print</code>.</p>
|
||||
<span class="hljs-keyword">return</span> watchErr err <span class="hljs-keyword">if</span> err
|
||||
compileScript(source, code.toString(), base)
|
||||
rewatch()
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">startWatcher</span> = -></span>
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">startWatcher</span> = -></span>
|
||||
watcher = fs.watch source
|
||||
.<span class="hljs-literal">on</span> <span class="hljs-string">'change'</span>, compile
|
||||
.<span class="hljs-literal">on</span> <span class="hljs-string">'error'</span>, <span class="hljs-function"><span class="hljs-params">(err)</span> -></span>
|
||||
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'EPERM'</span>
|
||||
removeSource source, base
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">rewatch</span> = -></span>
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">rewatch</span> = -></span>
|
||||
watcher?.close()
|
||||
startWatcher()
|
||||
|
||||
@@ -541,8 +552,8 @@ such as <code>--print</code>.</p>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">watchDir</span> = <span class="hljs-params">(source, base)</span> -></span>
|
||||
watcher = <span class="hljs-literal">null</span>
|
||||
readdirTimeout = <span class="hljs-literal">null</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">startWatcher</span> = -></span>
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">startWatcher</span> = -></span>
|
||||
watcher = fs.watch source
|
||||
.<span class="hljs-literal">on</span> <span class="hljs-string">'error'</span>, <span class="hljs-function"><span class="hljs-params">(err)</span> -></span>
|
||||
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'EPERM'</span>
|
||||
@@ -557,8 +568,8 @@ such as <code>--print</code>.</p>
|
||||
<span class="hljs-keyword">return</span> stopWatcher()
|
||||
<span class="hljs-keyword">for</span> file <span class="hljs-keyword">in</span> files
|
||||
compilePath (path.join source, file), <span class="hljs-literal">no</span>, base
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">stopWatcher</span> = -></span>
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">stopWatcher</span> = -></span>
|
||||
watcher.close()
|
||||
removeSourceDir source, base
|
||||
|
||||
@@ -567,8 +578,8 @@ such as <code>--print</code>.</p>
|
||||
startWatcher()
|
||||
<span class="hljs-keyword">catch</span> err
|
||||
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">removeSourceDir</span> = <span class="hljs-params">(source, base)</span> -></span>
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">removeSourceDir</span> = <span class="hljs-params">(source, base)</span> -></span>
|
||||
<span class="hljs-keyword">delete</span> watchedDirs[source]
|
||||
sourcesChanged = <span class="hljs-literal">no</span>
|
||||
<span class="hljs-keyword">for</span> file <span class="hljs-keyword">in</span> sources <span class="hljs-keyword">when</span> source <span class="hljs-keyword">is</span> path.dirname file
|
||||
@@ -598,8 +609,8 @@ the compiled JS version as well.</p>
|
||||
silentUnlink outputPath source, base
|
||||
silentUnlink outputPath source, base, <span class="hljs-string">'.js.map'</span>
|
||||
timeLog <span class="hljs-string">"removed <span class="hljs-subst">#{source}</span>"</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">silentUnlink</span> = <span class="hljs-params">(path)</span> -></span>
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">silentUnlink</span> = <span class="hljs-params">(path)</span> -></span>
|
||||
<span class="hljs-keyword">try</span>
|
||||
fs.unlinkSync path
|
||||
<span class="hljs-keyword">catch</span> err
|
||||
@@ -645,7 +656,7 @@ the compiled JS version as well.</p>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">mkdirp</span> = <span class="hljs-params">(dir, fn)</span> -></span>
|
||||
mode = <span class="hljs-number">0</span>o777 & ~process.umask()
|
||||
|
||||
<span class="hljs-keyword">do</span> m<span class="hljs-function"><span class="hljs-title">kdirs</span> = <span class="hljs-params">(p = dir, fn)</span> -></span>
|
||||
<span class="hljs-keyword">do</span> <span class="hljs-function"><span class="hljs-title">mkdirs</span> = <span class="hljs-params">(p = dir, fn)</span> -></span>
|
||||
fs.exists p, <span class="hljs-function"><span class="hljs-params">(exists)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> exists
|
||||
fn()
|
||||
@@ -675,7 +686,7 @@ same directory as the <code>.js</code> file.</p>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">writeJs</span> = <span class="hljs-params">(base, sourcePath, js, jsPath, generatedSourceMap = <span class="hljs-literal">null</span>)</span> -></span>
|
||||
sourceMapPath = outputPath sourcePath, base, <span class="hljs-string">".js.map"</span>
|
||||
jsDir = path.dirname jsPath
|
||||
<span class="hljs-function"> <span class="hljs-title">compile</span> = -></span>
|
||||
<span class="hljs-function"><span class="hljs-title">compile</span> = -></span>
|
||||
<span class="hljs-keyword">if</span> opts.compile
|
||||
js = <span class="hljs-string">' '</span> <span class="hljs-keyword">if</span> js.length <= <span class="hljs-number">0</span>
|
||||
<span class="hljs-keyword">if</span> generatedSourceMap <span class="hljs-keyword">then</span> js = <span class="hljs-string">"<span class="hljs-subst">#{js}</span>\n//# sourceMappingURL=<span class="hljs-subst">#{helpers.baseFileName sourceMapPath, <span class="hljs-literal">no</span>, useWinPathSep}</span>\n"</span>
|
||||
@@ -825,7 +836,7 @@ the <code>node</code> binary, preserving the other options.</p>
|
||||
p = spawn process.execPath, nodeArgs.concat(args),
|
||||
<span class="hljs-attribute">cwd</span>: process.cwd()
|
||||
<span class="hljs-attribute">env</span>: process.env
|
||||
<span class="hljs-attribute">customFds</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>]
|
||||
<span class="hljs-attribute">stdio</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>]
|
||||
p.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function"><span class="hljs-params">(code)</span> -></span> process.exit code</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'novecento-bold';
|
||||
src: url('public/fonts/novecento-bold.eot');
|
||||
src: url('public/fonts/novecento-bold.eot?#iefix') format('embedded-opentype'),
|
||||
url('public/fonts/novecento-bold.woff') format('woff'),
|
||||
url('public/fonts/novecento-bold.ttf') format('truetype');
|
||||
font-family: 'roboto-black';
|
||||
src: url('public/fonts/roboto-black.eot');
|
||||
src: url('public/fonts/roboto-black.eot?#iefix') format('embedded-opentype'),
|
||||
url('public/fonts/roboto-black.woff') format('woff'),
|
||||
url('public/fonts/roboto-black.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ h1, h2, h3, h4, h5, h6 {
|
||||
color: #112233;
|
||||
line-height: 1em;
|
||||
font-weight: normal;
|
||||
font-family: "novecento-bold";
|
||||
font-family: "roboto-black";
|
||||
text-transform: uppercase;
|
||||
margin: 30px 0 15px 0;
|
||||
}
|
||||
@@ -75,6 +75,9 @@ h1, h2, h3, h4, h5, h6 {
|
||||
h1 {
|
||||
margin-top: 40px;
|
||||
}
|
||||
h2 {
|
||||
font-size: 1.26em;
|
||||
}
|
||||
|
||||
hr {
|
||||
border: 0;
|
||||
|
||||
@@ -243,7 +243,7 @@ just be passed through unaffected.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"> <span class="hljs-title">addLocationDataFn</span> = <span class="hljs-params">(first, last)</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-function"><span class="hljs-title">addLocationDataFn</span> = <span class="hljs-params">(first, last)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> last
|
||||
<span class="hljs-string">"yy.addLocationDataFn(@<span class="hljs-subst">#{first}</span>)"</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
@@ -460,7 +460,17 @@ they can also serve as keys in object literals.</p>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">AlphaNumeric</span>: [
|
||||
o <span class="hljs-string">'NUMBER'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Literal $<span class="hljs-number">1</span>
|
||||
o <span class="hljs-string">'String'</span>
|
||||
]
|
||||
|
||||
<span class="hljs-attribute">String</span>: [
|
||||
o <span class="hljs-string">'STRING'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Literal $<span class="hljs-number">1</span>
|
||||
o <span class="hljs-string">'STRING_START Body STRING_END'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Parens $<span class="hljs-number">2</span>
|
||||
]
|
||||
|
||||
<span class="hljs-attribute">Regex</span>: [
|
||||
o <span class="hljs-string">'REGEX'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Literal $<span class="hljs-number">1</span>
|
||||
o <span class="hljs-string">'REGEX_START Invocation REGEX_END'</span>,<span class="hljs-function"> -></span> $<span class="hljs-number">2</span>
|
||||
]</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -480,7 +490,7 @@ through and printed to JavaScript.</p>
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">Literal</span>: [
|
||||
o <span class="hljs-string">'AlphaNumeric'</span>
|
||||
o <span class="hljs-string">'JS'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Literal $<span class="hljs-number">1</span>
|
||||
o <span class="hljs-string">'REGEX'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Literal $<span class="hljs-number">1</span>
|
||||
o <span class="hljs-string">'Regex'</span>
|
||||
o <span class="hljs-string">'DEBUGGER'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Literal $<span class="hljs-number">1</span>
|
||||
o <span class="hljs-string">'UNDEFINED'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Undefined
|
||||
o <span class="hljs-string">'NULL'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Null
|
||||
@@ -522,16 +532,27 @@ the ordinary <strong>Assign</strong> is that these allow numbers and strings as
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">AssignObj</span>: [
|
||||
o <span class="hljs-string">'ObjAssignable'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Value $<span class="hljs-number">1</span>
|
||||
o <span class="hljs-string">'ObjAssignable : Expression'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Assign LOC(<span class="hljs-number">1</span>)(<span class="hljs-keyword">new</span> Value($<span class="hljs-number">1</span>)), $<span class="hljs-number">3</span>, <span class="hljs-string">'object'</span>
|
||||
o <span class="hljs-string">'ObjAssignable : Expression'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Assign LOC(<span class="hljs-number">1</span>)(<span class="hljs-keyword">new</span> Value $<span class="hljs-number">1</span>), $<span class="hljs-number">3</span>, <span class="hljs-string">'object'</span>,
|
||||
<span class="hljs-attribute">operatorToken</span>: LOC(<span class="hljs-number">2</span>)(<span class="hljs-keyword">new</span> Literal $<span class="hljs-number">2</span>)
|
||||
o <span class="hljs-string">'ObjAssignable :
|
||||
INDENT Expression OUTDENT'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Assign LOC(<span class="hljs-number">1</span>)(<span class="hljs-keyword">new</span> Value($<span class="hljs-number">1</span>)), $<span class="hljs-number">4</span>, <span class="hljs-string">'object'</span>
|
||||
INDENT Expression OUTDENT'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Assign LOC(<span class="hljs-number">1</span>)(<span class="hljs-keyword">new</span> Value $<span class="hljs-number">1</span>), $<span class="hljs-number">4</span>, <span class="hljs-string">'object'</span>,
|
||||
<span class="hljs-attribute">operatorToken</span>: LOC(<span class="hljs-number">2</span>)(<span class="hljs-keyword">new</span> Literal $<span class="hljs-number">2</span>)
|
||||
o <span class="hljs-string">'SimpleObjAssignable = Expression'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Assign LOC(<span class="hljs-number">1</span>)(<span class="hljs-keyword">new</span> Value $<span class="hljs-number">1</span>), $<span class="hljs-number">3</span>, <span class="hljs-literal">null</span>,
|
||||
<span class="hljs-attribute">operatorToken</span>: LOC(<span class="hljs-number">2</span>)(<span class="hljs-keyword">new</span> Literal $<span class="hljs-number">2</span>)
|
||||
o <span class="hljs-string">'SimpleObjAssignable =
|
||||
INDENT Expression OUTDENT'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Assign LOC(<span class="hljs-number">1</span>)(<span class="hljs-keyword">new</span> Value $<span class="hljs-number">1</span>), $<span class="hljs-number">4</span>, <span class="hljs-literal">null</span>,
|
||||
<span class="hljs-attribute">operatorToken</span>: LOC(<span class="hljs-number">2</span>)(<span class="hljs-keyword">new</span> Literal $<span class="hljs-number">2</span>)
|
||||
o <span class="hljs-string">'Comment'</span>
|
||||
]
|
||||
|
||||
<span class="hljs-attribute">ObjAssignable</span>: [
|
||||
<span class="hljs-attribute">SimpleObjAssignable</span>: [
|
||||
o <span class="hljs-string">'Identifier'</span>
|
||||
o <span class="hljs-string">'AlphaNumeric'</span>
|
||||
o <span class="hljs-string">'ThisProperty'</span>
|
||||
]
|
||||
|
||||
<span class="hljs-attribute">ObjAssignable</span>: [
|
||||
o <span class="hljs-string">'SimpleObjAssignable'</span>
|
||||
o <span class="hljs-string">'AlphaNumeric'</span>
|
||||
]</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -1593,7 +1614,7 @@ precedence from low to high, and we have it high to low
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.parser = <span class="hljs-keyword">new</span> Parser
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.parser = <span class="hljs-keyword">new</span> Parser
|
||||
tokens : tokens.join <span class="hljs-string">' '</span>
|
||||
bnf : grammar
|
||||
operators : operators.reverse()
|
||||
|
||||
@@ -134,7 +134,7 @@ arrays, count characters, that sort of thing.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.s<span class="hljs-function"><span class="hljs-title">tarts</span> = <span class="hljs-params">(string, literal, start)</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">starts</span> = <span class="hljs-params">(string, literal, start)</span> -></span>
|
||||
literal <span class="hljs-keyword">is</span> string.substr start, literal.length</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -150,7 +150,7 @@ arrays, count characters, that sort of thing.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.e<span class="hljs-function"><span class="hljs-title">nds</span> = <span class="hljs-params">(string, literal, back)</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">ends</span> = <span class="hljs-params">(string, literal, back)</span> -></span>
|
||||
len = literal.length
|
||||
literal <span class="hljs-keyword">is</span> string.substr string.length - len - (back <span class="hljs-keyword">or</span> <span class="hljs-number">0</span>), len</pre></div></div>
|
||||
|
||||
@@ -167,7 +167,7 @@ arrays, count characters, that sort of thing.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.repeat = r<span class="hljs-function"><span class="hljs-title">epeat</span> = <span class="hljs-params">(str, n)</span> -></span></pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.repeat = <span class="hljs-function"><span class="hljs-title">repeat</span> = <span class="hljs-params">(str, n)</span> -></span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -202,7 +202,7 @@ arrays, count characters, that sort of thing.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.c<span class="hljs-function"><span class="hljs-title">ompact</span> = <span class="hljs-params">(array)</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">compact</span> = <span class="hljs-params">(array)</span> -></span>
|
||||
item <span class="hljs-keyword">for</span> item <span class="hljs-keyword">in</span> array <span class="hljs-keyword">when</span> item</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -218,7 +218,7 @@ arrays, count characters, that sort of thing.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.c<span class="hljs-function"><span class="hljs-title">ount</span> = <span class="hljs-params">(string, substr)</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">count</span> = <span class="hljs-params">(string, substr)</span> -></span>
|
||||
num = pos = <span class="hljs-number">0</span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span>/<span class="hljs-number">0</span> <span class="hljs-keyword">unless</span> substr.length
|
||||
num++ <span class="hljs-keyword">while</span> pos = <span class="hljs-number">1</span> + string.indexOf substr, pos
|
||||
@@ -239,7 +239,7 @@ options hash to propagate down the tree without polluting other branches.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.m<span class="hljs-function"><span class="hljs-title">erge</span> = <span class="hljs-params">(options, overrides)</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">merge</span> = <span class="hljs-params">(options, overrides)</span> -></span>
|
||||
extend (extend {}, options), overrides</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -255,7 +255,7 @@ options hash to propagate down the tree without polluting other branches.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>extend = exports.e<span class="hljs-function"><span class="hljs-title">xtend</span> = <span class="hljs-params">(object, properties)</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre>extend = <span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">extend</span> = <span class="hljs-params">(object, properties)</span> -></span>
|
||||
<span class="hljs-keyword">for</span> key, val <span class="hljs-keyword">of</span> properties
|
||||
object[key] = val
|
||||
object</pre></div></div>
|
||||
@@ -274,10 +274,10 @@ Handy for getting a list of <code>children</code> from the nodes.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.flatten = f<span class="hljs-function"><span class="hljs-title">latten</span> = <span class="hljs-params">(array)</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.flatten = <span class="hljs-function"><span class="hljs-title">flatten</span> = <span class="hljs-params">(array)</span> -></span>
|
||||
flattened = []
|
||||
<span class="hljs-keyword">for</span> element <span class="hljs-keyword">in</span> array
|
||||
<span class="hljs-keyword">if</span> element <span class="hljs-keyword">instanceof</span> Array
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-string">'[object Array]'</span> <span class="hljs-keyword">is</span> <span class="hljs-attribute">Object</span>::toString.call element
|
||||
flattened = flattened.concat flatten element
|
||||
<span class="hljs-keyword">else</span>
|
||||
flattened.push element
|
||||
@@ -297,7 +297,7 @@ looking for a particular method in an options hash.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.d<span class="hljs-function"><span class="hljs-title">el</span> = <span class="hljs-params">(obj, key)</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">del</span> = <span class="hljs-params">(obj, key)</span> -></span>
|
||||
val = obj[key]
|
||||
<span class="hljs-keyword">delete</span> obj[key]
|
||||
val</pre></div></div>
|
||||
@@ -311,11 +311,13 @@ looking for a particular method in an options hash.</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>Gets the last item of an array(-like) object.</p>
|
||||
<p>Typical Array::some</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.last = l<span class="hljs-function"><span class="hljs-title">ast</span> = <span class="hljs-params">(array, back)</span> -></span> array[array.length - (back <span class="hljs-keyword">or</span> <span class="hljs-number">0</span>) - <span class="hljs-number">1</span>]</pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.some = <span class="hljs-attribute">Array</span>::some ? <span class="hljs-function"><span class="hljs-params">(fn)</span> -></span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-literal">true</span> <span class="hljs-keyword">for</span> e <span class="hljs-keyword">in</span> <span class="hljs-keyword">this</span> <span class="hljs-keyword">when</span> fn e
|
||||
<span class="hljs-literal">false</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -326,30 +328,13 @@ looking for a particular method in an options hash.</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
</div>
|
||||
<p>Typical Array::some</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.some = <span class="hljs-attribute">Array</span>::some ? <span class="hljs-function"><span class="hljs-params">(fn)</span> -></span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-literal">true</span> <span class="hljs-keyword">for</span> e <span class="hljs-keyword">in</span> <span class="hljs-keyword">this</span> <span class="hljs-keyword">when</span> fn e
|
||||
<span class="hljs-literal">false</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-14">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
</div>
|
||||
<p>Simple function for inverting Literate CoffeeScript code by putting the
|
||||
documentation in comments, producing a string of CoffeeScript code that
|
||||
can be compiled “normally”.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.i<span class="hljs-function"><span class="hljs-title">nvertLiterate</span> = <span class="hljs-params">(code)</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">invertLiterate</span> = <span class="hljs-params">(code)</span> -></span>
|
||||
maybe_code = <span class="hljs-literal">true</span>
|
||||
lines = <span class="hljs-keyword">for</span> line <span class="hljs-keyword">in</span> code.split(<span class="hljs-string">'\n'</span>)
|
||||
<span class="hljs-keyword">if</span> maybe_code <span class="hljs-keyword">and</span> <span class="hljs-regexp">/^([ ]{4}|[ ]{0,3}\t)/</span>.test line
|
||||
@@ -363,11 +348,11 @@ can be compiled “normally”.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-15">
|
||||
<li id="section-14">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
</div>
|
||||
<p>Merge two jison-style location data objects together.
|
||||
If <code>last</code> is not provided, this will simply return <code>first</code>.</p>
|
||||
@@ -386,11 +371,11 @@ If <code>last</code> is not provided, this will simply return <code>first</code>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-16">
|
||||
<li id="section-15">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
</div>
|
||||
<p>This returns a function which takes an object as a parameter, and if that
|
||||
object is an AST node, updates that object’s locationData.
|
||||
@@ -398,8 +383,8 @@ The object is returned either way.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.a<span class="hljs-function"><span class="hljs-title">ddLocationDataFn</span> = <span class="hljs-params">(first, last)</span> -></span>
|
||||
<span class="hljs-function"> <span class="hljs-params">(obj)</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">addLocationDataFn</span> = <span class="hljs-params">(first, last)</span> -></span>
|
||||
<span class="hljs-function"><span class="hljs-params">(obj)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> ((<span class="hljs-keyword">typeof</span> obj) <span class="hljs-keyword">is</span> <span class="hljs-string">'object'</span>) <span class="hljs-keyword">and</span> (!!obj[<span class="hljs-string">'updateLocationDataIfMissing'</span>])
|
||||
obj.updateLocationDataIfMissing buildLocationData(first, last)
|
||||
|
||||
@@ -408,18 +393,18 @@ The object is returned either way.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-17">
|
||||
<li id="section-16">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
</div>
|
||||
<p>Convert jison location data to a string.
|
||||
<code>obj</code> can be a token, or a locationData.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.l<span class="hljs-function"><span class="hljs-title">ocationDataToString</span> = <span class="hljs-params">(obj)</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">locationDataToString</span> = <span class="hljs-params">(obj)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> (<span class="hljs-string">"2"</span> <span class="hljs-keyword">of</span> obj) <span class="hljs-keyword">and</span> (<span class="hljs-string">"first_line"</span> <span class="hljs-keyword">of</span> obj[<span class="hljs-number">2</span>]) <span class="hljs-keyword">then</span> locationData = obj[<span class="hljs-number">2</span>]
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> <span class="hljs-string">"first_line"</span> <span class="hljs-keyword">of</span> obj <span class="hljs-keyword">then</span> locationData = obj
|
||||
|
||||
@@ -432,18 +417,18 @@ The object is returned either way.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-18">
|
||||
<li id="section-17">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
</div>
|
||||
<p>A <code>.coffee.md</code> compatible version of <code>basename</code>, that returns the file sans-extension.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.b<span class="hljs-function"><span class="hljs-title">aseFileName</span> = <span class="hljs-params">(file, stripExt = <span class="hljs-literal">no</span>, useWinPathSep = <span class="hljs-literal">no</span>)</span> -></span>
|
||||
pathSep = <span class="hljs-keyword">if</span> useWinPathSep <span class="hljs-keyword">then</span> <span class="hljs-regexp">/\\|\//</span> <span class="hljs-keyword">else</span> <span class="hljs-regexp">/\//</span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">baseFileName</span> = <span class="hljs-params">(file, stripExt = <span class="hljs-literal">no</span>, useWinPathSep = <span class="hljs-literal">no</span>)</span> -></span>
|
||||
pathSep = <span class="hljs-keyword">if</span> useWinPathSep <span class="hljs-keyword">then</span> <span class="hljs-regexp">/\\|\//</span> <span class="hljs-keyword">else</span> <span class="hljs-regexp">/\/</span>/
|
||||
parts = file.split(pathSep)
|
||||
file = parts[parts.length - <span class="hljs-number">1</span>]
|
||||
<span class="hljs-keyword">return</span> file <span class="hljs-keyword">unless</span> stripExt <span class="hljs-keyword">and</span> file.indexOf(<span class="hljs-string">'.'</span>) >= <span class="hljs-number">0</span>
|
||||
@@ -455,17 +440,32 @@ The object is returned either way.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-18">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
</div>
|
||||
<p>Determine if a filename represents a CoffeeScript file.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">isCoffee</span> = <span class="hljs-params">(file)</span> -></span> <span class="hljs-regexp">/\.((lit)?coffee|coffee\.md)$/</span>.test file</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-19">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
</div>
|
||||
<p>Determine if a filename represents a CoffeeScript file.</p>
|
||||
<p>Determine if a filename represents a Literate CoffeeScript file.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.i<span class="hljs-function"><span class="hljs-title">sCoffee</span> = <span class="hljs-params">(file)</span> -></span> <span class="hljs-regexp">/\.((lit)?coffee|coffee\.md)$/</span>.test file</pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">isLiterate</span> = <span class="hljs-params">(file)</span> -></span> <span class="hljs-regexp">/\.(litcoffee|coffee\.md)$/</span>.test file</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -476,11 +476,17 @@ The object is returned either way.</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
</div>
|
||||
<p>Determine if a filename represents a Literate CoffeeScript file.</p>
|
||||
<p>Throws a SyntaxError from a given location.
|
||||
The error’s <code>toString</code> will return an error message following the “standard”
|
||||
format <filename>:<line>:<col>: <message> plus the line with the error and a
|
||||
marker showing where the error is.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.i<span class="hljs-function"><span class="hljs-title">sLiterate</span> = <span class="hljs-params">(file)</span> -></span> <span class="hljs-regexp">/\.(litcoffee|coffee\.md)$/</span>.test file</pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">throwSyntaxError</span> = <span class="hljs-params">(message, location)</span> -></span>
|
||||
error = <span class="hljs-keyword">new</span> SyntaxError message
|
||||
error.location = location
|
||||
error.toString = syntaxErrorToString</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -491,27 +497,6 @@ The object is returned either way.</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
</div>
|
||||
<p>Throws a SyntaxError from a given location.
|
||||
The error’s <code>toString</code> will return an error message following the “standard”
|
||||
format <filename>:<line>:<col>: <message> plus the line with the error and a
|
||||
marker showing where the error is.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.t<span class="hljs-function"><span class="hljs-title">hrowSyntaxError</span> = <span class="hljs-params">(message, location)</span> -></span>
|
||||
error = <span class="hljs-keyword">new</span> SyntaxError message
|
||||
error.location = location
|
||||
error.toString = syntaxErrorToString</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-22">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
</div>
|
||||
<p>Instead of showing the compiler’s stacktrace, show our custom error message
|
||||
(this is useful when the error bubbles up in Node.js applications that
|
||||
compile CoffeeScript for example).</p>
|
||||
@@ -525,27 +510,27 @@ compile CoffeeScript for example).</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-23">
|
||||
<li id="section-22">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
</div>
|
||||
<p>Update a compiler SyntaxError with source code information if it didn’t have
|
||||
it already.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.u<span class="hljs-function"><span class="hljs-title">pdateSyntaxError</span> = <span class="hljs-params">(error, code, filename)</span> -></span></pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">updateSyntaxError</span> = <span class="hljs-params">(error, code, filename)</span> -></span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-24">
|
||||
<li id="section-23">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
</div>
|
||||
<p>Avoid screwing up the <code>stack</code> property of other errors (i.e. possible bugs).</p>
|
||||
|
||||
@@ -556,8 +541,8 @@ it already.</p>
|
||||
error.filename <span class="hljs-keyword">or</span>= filename
|
||||
error.stack = error.toString()
|
||||
error
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">syntaxErrorToString</span> = -></span>
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">syntaxErrorToString</span> = -></span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-attribute">Error</span>::toString.call @ <span class="hljs-keyword">unless</span> <span class="hljs-property">@code</span> <span class="hljs-keyword">and</span> <span class="hljs-property">@location</span>
|
||||
|
||||
{first_line, first_column, last_line, last_column} = <span class="hljs-property">@location</span>
|
||||
@@ -571,11 +556,11 @@ it already.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-25">
|
||||
<li id="section-24">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-25">¶</a>
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
</div>
|
||||
<p>Show only the first line on multi-line errors.</p>
|
||||
|
||||
@@ -587,21 +572,21 @@ it already.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-26">
|
||||
<li id="section-25">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-26">¶</a>
|
||||
<a class="pilcrow" href="#section-25">¶</a>
|
||||
</div>
|
||||
<p>Check to see if we’re running on a color-enabled TTY.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> process?
|
||||
colorsEnabled = process.stdout.isTTY <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> process.env.NODE_DISABLE_COLORS
|
||||
colorsEnabled = process.stdout?.isTTY <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> process.env?.NODE_DISABLE_COLORS
|
||||
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-property">@colorful</span> ? colorsEnabled
|
||||
<span class="hljs-function"> <span class="hljs-title">colorize</span> = <span class="hljs-params">(str)</span> -></span> <span class="hljs-string">"\x1B[1;31m<span class="hljs-subst">#{str}</span>\x1B[0m"</span>
|
||||
<span class="hljs-function"><span class="hljs-title">colorize</span> = <span class="hljs-params">(str)</span> -></span> <span class="hljs-string">"\x1B[1;31m<span class="hljs-subst">#{str}</span>\x1B[0m"</span>
|
||||
codeLine = codeLine[...start] + colorize(codeLine[start...end]) + codeLine[end..]
|
||||
marker = colorize marker
|
||||
|
||||
@@ -611,7 +596,7 @@ it already.</p>
|
||||
<span class="hljs-subst">#{marker}</span>
|
||||
"""</span>
|
||||
|
||||
exports.n<span class="hljs-function"><span class="hljs-title">ameWhitespaceCharacter</span> = <span class="hljs-params">(string)</span> -></span>
|
||||
<span class="hljs-built_in">exports</span>.<span class="hljs-function"><span class="hljs-title">nameWhitespaceCharacter</span> = <span class="hljs-params">(string)</span> -></span>
|
||||
<span class="hljs-keyword">switch</span> string
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-string">' '</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'space'</span>
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-string">'\n'</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'newline'</span>
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports[key] = val <span class="hljs-keyword">for</span> key, val <span class="hljs-keyword">of</span> <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffee-script'</span></pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>[key] = val <span class="hljs-keyword">for</span> key, val <span class="hljs-keyword">of</span> <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffee-script'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ are read by jison in the <code>parser.lexer</code> function defined in coffee-sc
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>{count, starts, compact, last, repeat, invertLiterate,
|
||||
<div class="content"><div class='highlight'><pre>{count, starts, compact, repeat, invertLiterate,
|
||||
locationDataToString, throwSyntaxError} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -185,7 +185,7 @@ pushing some extra smarts into the Lexer.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.Lexer = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Lexer</span></span></pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.Lexer = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Lexer</span></span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -216,6 +216,7 @@ it has consumed.</p>
|
||||
<span class="hljs-property">@indents</span> = [] <span class="hljs-comment"># The stack of all current indentation levels.</span>
|
||||
<span class="hljs-property">@ends</span> = [] <span class="hljs-comment"># The stack for pairing up tokens.</span>
|
||||
<span class="hljs-property">@tokens</span> = [] <span class="hljs-comment"># Stream of parsed tokens in the form `['TYPE', value, location data]`.</span>
|
||||
<span class="hljs-property">@seenFor</span> = <span class="hljs-literal">no</span> <span class="hljs-comment"># Used to recognize FORIN and FOROF tokens.</span>
|
||||
|
||||
<span class="hljs-property">@chunkLine</span> =
|
||||
opts.line <span class="hljs-keyword">or</span> <span class="hljs-number">0</span> <span class="hljs-comment"># The start line for the current @chunk.</span>
|
||||
@@ -271,7 +272,7 @@ short-circuiting if any of them succeed. Their order determines precedence:
|
||||
<span class="hljs-keyword">return</span> {<span class="hljs-property">@tokens</span>, <span class="hljs-attribute">index</span>: i} <span class="hljs-keyword">if</span> opts.untilBalanced <span class="hljs-keyword">and</span> <span class="hljs-property">@ends</span>.length <span class="hljs-keyword">is</span> <span class="hljs-number">0</span>
|
||||
|
||||
<span class="hljs-property">@closeIndentation</span>()
|
||||
throwSyntaxError <span class="hljs-string">"missing <span class="hljs-subst">#{end.tag}</span>"</span>, end.origin[<span class="hljs-number">2</span>] <span class="hljs-keyword">if</span> end = <span class="hljs-property">@ends</span>.pop()
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"missing <span class="hljs-subst">#{end.tag}</span>"</span>, end.origin[<span class="hljs-number">2</span>] <span class="hljs-keyword">if</span> end = <span class="hljs-property">@ends</span>.pop()
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-property">@tokens</span> <span class="hljs-keyword">if</span> opts.rewrite <span class="hljs-keyword">is</span> <span class="hljs-literal">off</span>
|
||||
(<span class="hljs-keyword">new</span> Rewriter).rewrite <span class="hljs-property">@tokens</span></pre></div></div>
|
||||
|
||||
@@ -368,8 +369,9 @@ though <code>is</code> means <code>===</code> otherwise.</p>
|
||||
<span class="hljs-keyword">if</span> id <span class="hljs-keyword">is</span> <span class="hljs-string">'from'</span> <span class="hljs-keyword">and</span> <span class="hljs-property">@tag</span>() <span class="hljs-keyword">is</span> <span class="hljs-string">'YIELD'</span>
|
||||
<span class="hljs-property">@token</span> <span class="hljs-string">'FROM'</span>, id
|
||||
<span class="hljs-keyword">return</span> id.length
|
||||
forcedIdentifier = colon <span class="hljs-keyword">or</span>
|
||||
(prev = last <span class="hljs-property">@tokens</span>) <span class="hljs-keyword">and</span> (prev[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> [<span class="hljs-string">'.'</span>, <span class="hljs-string">'?.'</span>, <span class="hljs-string">'::'</span>, <span class="hljs-string">'?::'</span>] <span class="hljs-keyword">or</span>
|
||||
[..., prev] = <span class="hljs-property">@tokens</span>
|
||||
forcedIdentifier = colon <span class="hljs-keyword">or</span> prev? <span class="hljs-keyword">and</span>
|
||||
(prev[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> [<span class="hljs-string">'.'</span>, <span class="hljs-string">'?.'</span>, <span class="hljs-string">'::'</span>, <span class="hljs-string">'?::'</span>] <span class="hljs-keyword">or</span>
|
||||
<span class="hljs-keyword">not</span> prev.spaced <span class="hljs-keyword">and</span> prev[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'@'</span>)
|
||||
tag = <span class="hljs-string">'IDENTIFIER'</span>
|
||||
|
||||
@@ -399,10 +401,12 @@ though <code>is</code> means <code>===</code> otherwise.</p>
|
||||
id = <span class="hljs-keyword">new</span> String id
|
||||
id.reserved = <span class="hljs-literal">yes</span>
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> id <span class="hljs-keyword">in</span> RESERVED
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"reserved word \"<span class="hljs-subst">#{id}</span>\""</span>
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"reserved word '<span class="hljs-subst">#{id}</span>'"</span>, <span class="hljs-attribute">length</span>: id.length
|
||||
|
||||
<span class="hljs-keyword">unless</span> forcedIdentifier
|
||||
id = COFFEE_ALIAS_MAP[id] <span class="hljs-keyword">if</span> id <span class="hljs-keyword">in</span> COFFEE_ALIASES
|
||||
<span class="hljs-keyword">if</span> id <span class="hljs-keyword">in</span> COFFEE_ALIASES
|
||||
alias = id
|
||||
id = COFFEE_ALIAS_MAP[id]
|
||||
tag = <span class="hljs-keyword">switch</span> id
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-string">'!'</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'UNARY'</span>
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-string">'=='</span>, <span class="hljs-string">'!='</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'COMPARE'</span>
|
||||
@@ -412,6 +416,7 @@ though <code>is</code> means <code>===</code> otherwise.</p>
|
||||
<span class="hljs-keyword">else</span> tag
|
||||
|
||||
tagToken = <span class="hljs-property">@token</span> tag, id, <span class="hljs-number">0</span>, idLength
|
||||
tagToken.origin = [tag, alias, tagToken[<span class="hljs-number">2</span>]] <span class="hljs-keyword">if</span> alias
|
||||
tagToken.variable = <span class="hljs-keyword">not</span> forcedIdentifier
|
||||
<span class="hljs-keyword">if</span> poppedToken
|
||||
[tagToken[<span class="hljs-number">2</span>].first_line, tagToken[<span class="hljs-number">2</span>].first_column] =
|
||||
@@ -439,15 +444,16 @@ Be careful not to interfere with ranges-in-progress.</p>
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">numberToken</span>:<span class="hljs-function"> -></span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">0</span> <span class="hljs-keyword">unless</span> match = NUMBER.exec <span class="hljs-property">@chunk</span>
|
||||
number = match[<span class="hljs-number">0</span>]
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-regexp">/^0[BOX]/</span>.test number
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"radix prefix '<span class="hljs-subst">#{number}</span>' must be lowercase"</span>
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> <span class="hljs-regexp">/E/</span>.test(number) <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> <span class="hljs-regexp">/^0x/</span>.test number
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"exponential notation '<span class="hljs-subst">#{number}</span>' must be indicated with a lowercase 'e'"</span>
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> <span class="hljs-regexp">/^0\d*[89]/</span>.test number
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"decimal literal '<span class="hljs-subst">#{number}</span>' must not be prefixed with '0'"</span>
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> <span class="hljs-regexp">/^0\d+/</span>.test number
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"octal literal '<span class="hljs-subst">#{number}</span>' must be prefixed with '0o'"</span>
|
||||
lexedLength = number.length
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-regexp">/^0[BOX]/</span>.test number
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"radix prefix in '<span class="hljs-subst">#{number}</span>' must be lowercase"</span>, <span class="hljs-attribute">offset</span>: <span class="hljs-number">1</span>
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> <span class="hljs-regexp">/E/</span>.test(number) <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> <span class="hljs-regexp">/^0x/</span>.test number
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"exponential notation in '<span class="hljs-subst">#{number}</span>' must be indicated with a lowercase 'e'"</span>,
|
||||
<span class="hljs-attribute">offset</span>: number.indexOf(<span class="hljs-string">'E'</span>)
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> <span class="hljs-regexp">/^0\d*[89]/</span>.test number
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"decimal literal '<span class="hljs-subst">#{number}</span>' must not be prefixed with '0'"</span>, <span class="hljs-attribute">length</span>: lexedLength
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> <span class="hljs-regexp">/^0\d+/</span>.test number
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"octal literal '<span class="hljs-subst">#{number}</span>' must be prefixed with '0o'"</span>, <span class="hljs-attribute">length</span>: lexedLength
|
||||
<span class="hljs-keyword">if</span> octalLiteral = <span class="hljs-regexp">/^0o([0-7]+)/</span>.exec number
|
||||
number = <span class="hljs-string">'0x'</span> + parseInt(octalLiteral[<span class="hljs-number">1</span>], <span class="hljs-number">8</span>).toString <span class="hljs-number">16</span>
|
||||
<span class="hljs-keyword">if</span> binaryLiteral = <span class="hljs-regexp">/^0b([01]+)/</span>.exec number
|
||||
@@ -479,10 +485,10 @@ interpolation.</p>
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-string">'"""'</span> <span class="hljs-keyword">then</span> HEREDOC_DOUBLE
|
||||
heredoc = quote.length <span class="hljs-keyword">is</span> <span class="hljs-number">3</span>
|
||||
|
||||
start = quote.length
|
||||
{tokens, <span class="hljs-attribute">index</span>: end} = <span class="hljs-property">@matchWithInterpolations</span> <span class="hljs-property">@chunk</span>[start..], regex, quote, start
|
||||
{tokens, <span class="hljs-attribute">index</span>: end} = <span class="hljs-property">@matchWithInterpolations</span> regex, quote
|
||||
$ = tokens.length - <span class="hljs-number">1</span>
|
||||
|
||||
delimiter = quote.charAt(<span class="hljs-number">0</span>)
|
||||
<span class="hljs-keyword">if</span> heredoc</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -504,17 +510,16 @@ interpolation.</p>
|
||||
attempt = match[<span class="hljs-number">1</span>]
|
||||
indent = attempt <span class="hljs-keyword">if</span> indent <span class="hljs-keyword">is</span> <span class="hljs-literal">null</span> <span class="hljs-keyword">or</span> <span class="hljs-number">0</span> < attempt.length < indent.length
|
||||
indentRegex = <span class="hljs-regexp">/// ^<span class="hljs-subst">#{indent}</span> ///</span>gm <span class="hljs-keyword">if</span> indent
|
||||
<span class="hljs-property">@mergeInterpolationTokens</span> tokens, {<span class="hljs-attribute">quote</span>: quote[<span class="hljs-number">0</span>], start, end}, <span class="hljs-function"><span class="hljs-params">(value, i)</span> =></span>
|
||||
<span class="hljs-property">@mergeInterpolationTokens</span> tokens, {delimiter}, <span class="hljs-function"><span class="hljs-params">(value, i)</span> =></span>
|
||||
value = <span class="hljs-property">@formatString</span> value
|
||||
value = value.replace LEADING_BLANK_LINE, <span class="hljs-string">''</span> <span class="hljs-keyword">if</span> i <span class="hljs-keyword">is</span> <span class="hljs-number">0</span>
|
||||
value = value.replace TRAILING_BLANK_LINE, <span class="hljs-string">''</span> <span class="hljs-keyword">if</span> i <span class="hljs-keyword">is</span> $
|
||||
value = value.replace indentRegex, <span class="hljs-string">''</span>
|
||||
value = value.replace MULTILINER, <span class="hljs-string">'\\n'</span>
|
||||
value = value.replace indentRegex, <span class="hljs-string">''</span> <span class="hljs-keyword">if</span> indentRegex
|
||||
value
|
||||
<span class="hljs-keyword">else</span>
|
||||
<span class="hljs-property">@mergeInterpolationTokens</span> tokens, {quote, start, end}, <span class="hljs-function"><span class="hljs-params">(value, i)</span> =></span>
|
||||
<span class="hljs-property">@mergeInterpolationTokens</span> tokens, {delimiter}, <span class="hljs-function"><span class="hljs-params">(value, i)</span> =></span>
|
||||
value = <span class="hljs-property">@formatString</span> value
|
||||
value = value.replace STRING_OMIT, <span class="hljs-function"><span class="hljs-params">(match, offset)</span> -></span>
|
||||
value = value.replace SIMPLE_STRING_OMIT, <span class="hljs-function"><span class="hljs-params">(match, offset)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> (i <span class="hljs-keyword">is</span> <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> offset <span class="hljs-keyword">is</span> <span class="hljs-number">0</span>) <span class="hljs-keyword">or</span>
|
||||
(i <span class="hljs-keyword">is</span> $ <span class="hljs-keyword">and</span> offset + match.length <span class="hljs-keyword">is</span> value.length)
|
||||
<span class="hljs-string">''</span>
|
||||
@@ -542,7 +547,8 @@ interpolation.</p>
|
||||
[comment, here] = match
|
||||
<span class="hljs-keyword">if</span> here
|
||||
<span class="hljs-keyword">if</span> match = HERECOMMENT_ILLEGAL.exec comment
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"block comments cannot contain <span class="hljs-subst">#{match[<span class="hljs-number">0</span>]}</span>"</span>, match.index
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"block comments cannot contain <span class="hljs-subst">#{match[<span class="hljs-number">0</span>]}</span>"</span>,
|
||||
<span class="hljs-attribute">offset</span>: match.index, <span class="hljs-attribute">length</span>: match[<span class="hljs-number">0</span>].length
|
||||
<span class="hljs-keyword">if</span> here.indexOf(<span class="hljs-string">'\n'</span>) >= <span class="hljs-number">0</span>
|
||||
here = here.replace <span class="hljs-regexp">/// \n <span class="hljs-subst">#{repeat <span class="hljs-string">' '</span>, <span class="hljs-property">@indent</span>}</span> ///</span>g, <span class="hljs-string">'\n'</span>
|
||||
<span class="hljs-property">@token</span> <span class="hljs-string">'HERECOMMENT'</span>, here, <span class="hljs-number">0</span>, comment.length
|
||||
@@ -584,15 +590,17 @@ borrow some basic heuristics from JavaScript and Ruby.</p>
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">regexToken</span>:<span class="hljs-function"> -></span>
|
||||
<span class="hljs-keyword">switch</span>
|
||||
<span class="hljs-keyword">when</span> match = REGEX_ILLEGAL.exec <span class="hljs-property">@chunk</span>
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"regular expressions cannot begin with <span class="hljs-subst">#{match[<span class="hljs-number">2</span>]}</span>"</span>, match.index + match[<span class="hljs-number">1</span>].length
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-property">@chunk</span>[..<span class="hljs-number">.3</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'///'</span>
|
||||
{tokens, index} = <span class="hljs-property">@matchWithInterpolations</span> <span class="hljs-property">@chunk</span>[<span class="hljs-number">3.</span>.], HEREGEX, <span class="hljs-string">'///'</span>, <span class="hljs-number">3</span>
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"regular expressions cannot begin with <span class="hljs-subst">#{match[<span class="hljs-number">2</span>]}</span>"</span>,
|
||||
<span class="hljs-attribute">offset</span>: match.index + match[<span class="hljs-number">1</span>].length
|
||||
<span class="hljs-keyword">when</span> match = <span class="hljs-property">@matchWithInterpolations</span> HEREGEX, <span class="hljs-string">'///'</span>
|
||||
{tokens, index} = match
|
||||
<span class="hljs-keyword">when</span> match = REGEX.exec <span class="hljs-property">@chunk</span>
|
||||
[regex, closed] = match
|
||||
[regex, body, closed] = match
|
||||
<span class="hljs-property">@validateEscapes</span> body, <span class="hljs-attribute">isRegex</span>: <span class="hljs-literal">yes</span>, <span class="hljs-attribute">offsetInChunk</span>: <span class="hljs-number">1</span>
|
||||
index = regex.length
|
||||
prev = last <span class="hljs-property">@tokens</span>
|
||||
[..., prev] = <span class="hljs-property">@tokens</span>
|
||||
<span class="hljs-keyword">if</span> prev
|
||||
<span class="hljs-keyword">if</span> prev.spaced <span class="hljs-keyword">and</span> prev[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> CALLABLE <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> prev.stringEnd <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> prev.regexEnd
|
||||
<span class="hljs-keyword">if</span> prev.spaced <span class="hljs-keyword">and</span> prev[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> CALLABLE
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">0</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> closed <span class="hljs-keyword">or</span> POSSIBLY_DIVISION.test regex
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> prev[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> NOT_REGEX
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">0</span>
|
||||
@@ -602,24 +610,23 @@ borrow some basic heuristics from JavaScript and Ruby.</p>
|
||||
|
||||
[flags] = REGEX_FLAGS.exec <span class="hljs-property">@chunk</span>[index..]
|
||||
end = index + flags.length
|
||||
origin = <span class="hljs-property">@makeToken</span> <span class="hljs-string">'REGEX'</span>, <span class="hljs-literal">null</span>, <span class="hljs-number">0</span>, end
|
||||
<span class="hljs-keyword">switch</span>
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-keyword">not</span> VALID_FLAGS.test flags
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"invalid regular expression flags <span class="hljs-subst">#{flags}</span>"</span>, index
|
||||
<span class="hljs-keyword">when</span> regex
|
||||
<span class="hljs-property">@token</span> <span class="hljs-string">'REGEX'</span>, <span class="hljs-string">"<span class="hljs-subst">#{regex}</span><span class="hljs-subst">#{flags}</span>"</span>
|
||||
<span class="hljs-keyword">when</span> tokens.length <span class="hljs-keyword">is</span> <span class="hljs-number">1</span>
|
||||
re = <span class="hljs-property">@formatHeregex</span>(tokens[<span class="hljs-number">0</span>][<span class="hljs-number">1</span>]).replace(<span class="hljs-regexp">/\//g</span>, <span class="hljs-string">'\\/'</span>)
|
||||
<span class="hljs-property">@token</span> <span class="hljs-string">'REGEX'</span>, <span class="hljs-string">"/<span class="hljs-subst">#{ re <span class="hljs-keyword">or</span> <span class="hljs-string">'(?:)'</span> }</span>/<span class="hljs-subst">#{flags}</span>"</span>
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"invalid regular expression flags <span class="hljs-subst">#{flags}</span>"</span>, <span class="hljs-attribute">offset</span>: index, <span class="hljs-attribute">length</span>: flags.length
|
||||
<span class="hljs-keyword">when</span> regex <span class="hljs-keyword">or</span> tokens.length <span class="hljs-keyword">is</span> <span class="hljs-number">1</span>
|
||||
body ?= <span class="hljs-property">@formatHeregex</span> tokens[<span class="hljs-number">0</span>][<span class="hljs-number">1</span>]
|
||||
<span class="hljs-property">@token</span> <span class="hljs-string">'REGEX'</span>, <span class="hljs-string">"<span class="hljs-subst">#{<span class="hljs-property">@makeDelimitedLiteral</span> body, delimiter: <span class="hljs-string">'/'</span>}</span><span class="hljs-subst">#{flags}</span>"</span>, <span class="hljs-number">0</span>, end, origin
|
||||
<span class="hljs-keyword">else</span>
|
||||
<span class="hljs-property">@token</span> <span class="hljs-string">'REGEX_START'</span>, <span class="hljs-string">'('</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, origin
|
||||
<span class="hljs-property">@token</span> <span class="hljs-string">'IDENTIFIER'</span>, <span class="hljs-string">'RegExp'</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>
|
||||
<span class="hljs-property">@token</span> <span class="hljs-string">'CALL_START'</span>, <span class="hljs-string">'('</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>
|
||||
<span class="hljs-property">@mergeInterpolationTokens</span> tokens, {<span class="hljs-attribute">quote</span>: <span class="hljs-string">'"'</span>, <span class="hljs-attribute">start</span>: <span class="hljs-number">3</span>, end}, <span class="hljs-function"><span class="hljs-params">(value)</span> =></span>
|
||||
<span class="hljs-property">@formatHeregex</span>(value).replace(<span class="hljs-regexp">/\\/g</span>, <span class="hljs-string">'\\\\'</span>)
|
||||
<span class="hljs-property">@mergeInterpolationTokens</span> tokens, {<span class="hljs-attribute">delimiter</span>: <span class="hljs-string">'"'</span>, <span class="hljs-attribute">double</span>: <span class="hljs-literal">yes</span>}, <span class="hljs-property">@formatHeregex</span>
|
||||
<span class="hljs-keyword">if</span> flags
|
||||
<span class="hljs-property">@token</span> <span class="hljs-string">','</span>, <span class="hljs-string">','</span>, index, <span class="hljs-number">0</span>
|
||||
<span class="hljs-property">@token</span> <span class="hljs-string">'STRING'</span>, <span class="hljs-string">'"'</span> + flags + <span class="hljs-string">'"'</span>, index, flags.length
|
||||
rparen = <span class="hljs-property">@token</span> <span class="hljs-string">')'</span>, <span class="hljs-string">')'</span>, end, <span class="hljs-number">0</span>
|
||||
rparen.regexEnd = <span class="hljs-literal">true</span>
|
||||
<span class="hljs-property">@token</span> <span class="hljs-string">')'</span>, <span class="hljs-string">')'</span>, end, <span class="hljs-number">0</span>
|
||||
<span class="hljs-property">@token</span> <span class="hljs-string">'REGEX_END'</span>, <span class="hljs-string">')'</span>, end, <span class="hljs-number">0</span>
|
||||
|
||||
end</pre></div></div>
|
||||
|
||||
@@ -668,7 +675,7 @@ can close multiple indents, so we need to know how far in we happen to be.</p>
|
||||
<span class="hljs-property">@outdebt</span> = <span class="hljs-property">@indebt</span> = <span class="hljs-number">0</span>
|
||||
<span class="hljs-property">@indent</span> = size
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> size < <span class="hljs-property">@baseIndent</span>
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">'missing indentation'</span>, indent.length
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">'missing indentation'</span>, <span class="hljs-attribute">offset</span>: indent.length
|
||||
<span class="hljs-keyword">else</span>
|
||||
<span class="hljs-property">@indebt</span> = <span class="hljs-number">0</span>
|
||||
<span class="hljs-property">@outdentToken</span> <span class="hljs-property">@indent</span> - size, noNewlines, indent.length
|
||||
@@ -747,7 +754,7 @@ as being “spaced”, because there are some cases where it makes a difference.
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">whitespaceToken</span>:<span class="hljs-function"> -></span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">0</span> <span class="hljs-keyword">unless</span> (match = WHITESPACE.exec <span class="hljs-property">@chunk</span>) <span class="hljs-keyword">or</span>
|
||||
(nline = <span class="hljs-property">@chunk</span>.charAt(<span class="hljs-number">0</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'\n'</span>)
|
||||
prev = last <span class="hljs-property">@tokens</span>
|
||||
[..., prev] = <span class="hljs-property">@tokens</span>
|
||||
prev[<span class="hljs-keyword">if</span> match <span class="hljs-keyword">then</span> <span class="hljs-string">'spaced'</span> <span class="hljs-keyword">else</span> <span class="hljs-string">'newLine'</span>] = <span class="hljs-literal">true</span> <span class="hljs-keyword">if</span> prev
|
||||
<span class="hljs-keyword">if</span> match <span class="hljs-keyword">then</span> match[<span class="hljs-number">0</span>].length <span class="hljs-keyword">else</span> <span class="hljs-number">0</span></pre></div></div>
|
||||
|
||||
@@ -811,10 +818,11 @@ parentheses that indicate a method call from regular parentheses, and so on.</p>
|
||||
<span class="hljs-keyword">else</span>
|
||||
value = <span class="hljs-property">@chunk</span>.charAt <span class="hljs-number">0</span>
|
||||
tag = value
|
||||
prev = last <span class="hljs-property">@tokens</span>
|
||||
[..., prev] = <span class="hljs-property">@tokens</span>
|
||||
<span class="hljs-keyword">if</span> value <span class="hljs-keyword">is</span> <span class="hljs-string">'='</span> <span class="hljs-keyword">and</span> prev
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> prev[<span class="hljs-number">1</span>].reserved <span class="hljs-keyword">and</span> prev[<span class="hljs-number">1</span>] <span class="hljs-keyword">in</span> JS_FORBIDDEN
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"reserved word \"<span class="hljs-subst">#{<span class="hljs-property">@value</span>()}</span>\" can't be assigned"</span>
|
||||
prev = prev.origin <span class="hljs-keyword">if</span> prev.origin
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"reserved word '<span class="hljs-subst">#{prev[<span class="hljs-number">1</span>]}</span>' can't be assigned"</span>, prev[<span class="hljs-number">2</span>]
|
||||
<span class="hljs-keyword">if</span> prev[<span class="hljs-number">1</span>] <span class="hljs-keyword">in</span> [<span class="hljs-string">'||'</span>, <span class="hljs-string">'&&'</span>]
|
||||
prev[<span class="hljs-number">0</span>] = <span class="hljs-string">'COMPOUND_ASSIGN'</span>
|
||||
prev[<span class="hljs-number">1</span>] += <span class="hljs-string">'='</span>
|
||||
@@ -830,7 +838,7 @@ parentheses that indicate a method call from regular parentheses, and so on.</p>
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> value <span class="hljs-keyword">in</span> SHIFT <span class="hljs-keyword">then</span> tag = <span class="hljs-string">'SHIFT'</span>
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> value <span class="hljs-keyword">in</span> LOGIC <span class="hljs-keyword">or</span> value <span class="hljs-keyword">is</span> <span class="hljs-string">'?'</span> <span class="hljs-keyword">and</span> prev?.spaced <span class="hljs-keyword">then</span> tag = <span class="hljs-string">'LOGIC'</span>
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> prev <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> prev.spaced
|
||||
<span class="hljs-keyword">if</span> value <span class="hljs-keyword">is</span> <span class="hljs-string">'('</span> <span class="hljs-keyword">and</span> prev[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> CALLABLE <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> prev.stringEnd <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> prev.regexEnd
|
||||
<span class="hljs-keyword">if</span> value <span class="hljs-keyword">is</span> <span class="hljs-string">'('</span> <span class="hljs-keyword">and</span> prev[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> CALLABLE
|
||||
prev[<span class="hljs-number">0</span>] = <span class="hljs-string">'FUNC_EXIST'</span> <span class="hljs-keyword">if</span> prev[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'?'</span>
|
||||
tag = <span class="hljs-string">'CALL_START'</span>
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> value <span class="hljs-keyword">is</span> <span class="hljs-string">'['</span> <span class="hljs-keyword">and</span> prev[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> INDEXABLE
|
||||
@@ -934,24 +942,25 @@ expressions.</p>
|
||||
</code></pre><p>If it encounters an interpolation, this method will recursively create a new
|
||||
Lexer and tokenize until the <code>{</code> of <code>#{</code> is balanced with a <code>}</code>.</p>
|
||||
<ul>
|
||||
<li><code>str</code> is the start of the token contents (with the starting delimiter
|
||||
stripped off.)</li>
|
||||
<li><code>regex</code> matches the contents of a token (but not <code>end</code>, and not <code>#{</code> if
|
||||
interpolations are desired).</li>
|
||||
<li><code>end</code> is the terminator of the token.</li>
|
||||
<li><code>offsetInChunk</code> is the start of the interpolated string in the current
|
||||
chunk, including the starting delimiter.</li>
|
||||
<li><code>regex</code> matches the contents of a token (but not <code>delimiter</code>, and not
|
||||
<code>#{</code> if interpolations are desired).</li>
|
||||
<li><code>delimiter</code> is the delimiter of the token. Examples are <code>'</code>, <code>"</code>, <code>'''</code>,
|
||||
<code>"""</code> and <code>///</code>.</li>
|
||||
</ul>
|
||||
<p>Examples of delimiters are <code>'</code>, <code>"</code>, <code>'''</code>, <code>"""</code> and <code>///</code>.</p>
|
||||
<p>This method allows us to have strings within interpolations within strings,
|
||||
ad infinitum.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">matchWithInterpolations</span>: <span class="hljs-function"><span class="hljs-params">(str, regex, end, offsetInChunk)</span> -></span>
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">matchWithInterpolations</span>: <span class="hljs-function"><span class="hljs-params">(regex, delimiter)</span> -></span>
|
||||
tokens = []
|
||||
offsetInChunk = delimiter.length
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-literal">null</span> <span class="hljs-keyword">unless</span> <span class="hljs-property">@chunk</span>[...offsetInChunk] <span class="hljs-keyword">is</span> delimiter
|
||||
str = <span class="hljs-property">@chunk</span>[offsetInChunk..]
|
||||
<span class="hljs-keyword">loop</span>
|
||||
[strPart] = regex.exec str</pre></div></div>
|
||||
[strPart] = regex.exec str
|
||||
|
||||
<span class="hljs-property">@validateEscapes</span> strPart, {<span class="hljs-attribute">isRegex</span>: delimiter.charAt(<span class="hljs-number">0</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'/'</span>, offsetInChunk}</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -1057,10 +1066,15 @@ parentheses will be removed later.</p>
|
||||
str = str[index..]
|
||||
offsetInChunk += index
|
||||
|
||||
<span class="hljs-keyword">unless</span> str[...end.length] <span class="hljs-keyword">is</span> end
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"missing <span class="hljs-subst">#{end}</span>"</span>
|
||||
<span class="hljs-keyword">unless</span> str[...delimiter.length] <span class="hljs-keyword">is</span> delimiter
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"missing <span class="hljs-subst">#{delimiter}</span>"</span>, <span class="hljs-attribute">length</span>: delimiter.length
|
||||
|
||||
{tokens, <span class="hljs-attribute">index</span>: offsetInChunk + end.length}</pre></div></div>
|
||||
[firstToken, ..., lastToken] = tokens
|
||||
firstToken[<span class="hljs-number">2</span>].first_column -= delimiter.length
|
||||
lastToken[<span class="hljs-number">2</span>].last_column += delimiter.length
|
||||
lastToken[<span class="hljs-number">2</span>].last_column -= <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> lastToken[<span class="hljs-number">1</span>].length <span class="hljs-keyword">is</span> <span class="hljs-number">0</span>
|
||||
|
||||
{tokens, <span class="hljs-attribute">index</span>: offsetInChunk + delimiter.length}</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -1074,15 +1088,13 @@ parentheses will be removed later.</p>
|
||||
<p>Merge the array <code>tokens</code> of the fake token types ‘TOKENS’ and ‘NEOSTRING’
|
||||
(as returned by <code>matchWithInterpolations</code>) into the token stream. The value
|
||||
of ‘NEOSTRING’s are converted using <code>fn</code> and turned into strings using
|
||||
<code>quote</code> first. The tokens are wrapped in parentheses if needed, using
|
||||
<code>start</code> and <code>end</code> for their location data.</p>
|
||||
<code>options</code> first.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">mergeInterpolationTokens</span>: <span class="hljs-function"><span class="hljs-params">(tokens, {quote, start, end}, fn)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> interpolated = tokens.length > <span class="hljs-number">1</span>
|
||||
errorToken = <span class="hljs-property">@makeToken</span> <span class="hljs-string">''</span>, <span class="hljs-string">'interpolation'</span>, start + tokens[<span class="hljs-number">0</span>][<span class="hljs-number">1</span>].length, <span class="hljs-number">2</span>
|
||||
<span class="hljs-property">@token</span> <span class="hljs-string">'('</span>, <span class="hljs-string">'('</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, errorToken
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">mergeInterpolationTokens</span>: <span class="hljs-function"><span class="hljs-params">(tokens, options, fn)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> tokens.length > <span class="hljs-number">1</span>
|
||||
lparen = <span class="hljs-property">@token</span> <span class="hljs-string">'STRING_START'</span>, <span class="hljs-string">'('</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>
|
||||
|
||||
firstIndex = <span class="hljs-property">@tokens</span>.length
|
||||
<span class="hljs-keyword">for</span> token, i <span class="hljs-keyword">in</span> tokens
|
||||
@@ -1176,7 +1188,7 @@ empty string.</p>
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> i <span class="hljs-keyword">is</span> <span class="hljs-number">2</span> <span class="hljs-keyword">and</span> firstEmptyStringIndex?
|
||||
<span class="hljs-property">@tokens</span>.splice firstEmptyStringIndex, <span class="hljs-number">2</span> <span class="hljs-comment"># Remove empty string and the plus.</span>
|
||||
token[<span class="hljs-number">0</span>] = <span class="hljs-string">'STRING'</span>
|
||||
token[<span class="hljs-number">1</span>] = <span class="hljs-property">@makeString</span> converted, quote
|
||||
token[<span class="hljs-number">1</span>] = <span class="hljs-property">@makeDelimitedLiteral</span> converted, options
|
||||
locationToken = token
|
||||
tokensToPush = [token]
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-property">@tokens</span>.length > firstIndex</pre></div></div>
|
||||
@@ -1202,9 +1214,20 @@ empty string.</p>
|
||||
<span class="hljs-attribute">last_column</span>: locationToken[<span class="hljs-number">2</span>].first_column
|
||||
<span class="hljs-property">@tokens</span>.push tokensToPush...
|
||||
|
||||
<span class="hljs-keyword">if</span> interpolated
|
||||
rparen = <span class="hljs-property">@token</span> <span class="hljs-string">')'</span>, <span class="hljs-string">')'</span>, end, <span class="hljs-number">0</span>
|
||||
rparen.stringEnd = <span class="hljs-literal">true</span></pre></div></div>
|
||||
<span class="hljs-keyword">if</span> lparen
|
||||
[..., lastToken] = tokens
|
||||
lparen.origin = [<span class="hljs-string">'STRING'</span>, <span class="hljs-literal">null</span>,
|
||||
<span class="hljs-attribute">first_line</span>: lparen[<span class="hljs-number">2</span>].first_line
|
||||
<span class="hljs-attribute">first_column</span>: lparen[<span class="hljs-number">2</span>].first_column
|
||||
<span class="hljs-attribute">last_line</span>: lastToken[<span class="hljs-number">2</span>].last_line
|
||||
<span class="hljs-attribute">last_column</span>: lastToken[<span class="hljs-number">2</span>].last_column
|
||||
]
|
||||
rparen = <span class="hljs-property">@token</span> <span class="hljs-string">'STRING_END'</span>, <span class="hljs-string">')'</span>
|
||||
rparen[<span class="hljs-number">2</span>] =
|
||||
<span class="hljs-attribute">first_line</span>: lastToken[<span class="hljs-number">2</span>].last_line
|
||||
<span class="hljs-attribute">first_column</span>: lastToken[<span class="hljs-number">2</span>].last_column
|
||||
<span class="hljs-attribute">last_line</span>: lastToken[<span class="hljs-number">2</span>].last_line
|
||||
<span class="hljs-attribute">last_column</span>: lastToken[<span class="hljs-number">2</span>].last_column</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -1221,7 +1244,8 @@ correctly balanced throughout the course of the token stream.</p>
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">pair</span>: <span class="hljs-function"><span class="hljs-params">(tag)</span> -></span>
|
||||
<span class="hljs-keyword">unless</span> tag <span class="hljs-keyword">is</span> wanted = last(<span class="hljs-property">@ends</span>)?.tag
|
||||
[..., prev] = <span class="hljs-property">@ends</span>
|
||||
<span class="hljs-keyword">unless</span> tag <span class="hljs-keyword">is</span> wanted = prev?.tag
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"unmatched <span class="hljs-subst">#{tag}</span>"</span> <span class="hljs-keyword">unless</span> <span class="hljs-string">'OUTDENT'</span> <span class="hljs-keyword">is</span> wanted</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -1234,12 +1258,13 @@ correctly balanced throughout the course of the token stream.</p>
|
||||
<a class="pilcrow" href="#section-46">¶</a>
|
||||
</div>
|
||||
<p>Auto-close INDENT to support syntax like this:</p>
|
||||
<pre><code>el.click(<span class="hljs-function"><span class="hljs-params">(event)</span> -></span>
|
||||
el.hide())
|
||||
<pre><code>el.click<span class="hljs-function"><span class="hljs-params">((event) ->
|
||||
el.hide())</span></span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-property">@outdentToken</span> last(<span class="hljs-property">@indents</span>), <span class="hljs-literal">true</span>
|
||||
<div class="content"><div class='highlight'><pre> [..., lastIndent] = <span class="hljs-property">@indents</span>
|
||||
<span class="hljs-property">@outdentToken</span> lastIndent, <span class="hljs-literal">true</span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-property">@pair</span> tag
|
||||
<span class="hljs-property">@ends</span>.pop()</pre></div></div>
|
||||
|
||||
@@ -1295,8 +1320,8 @@ correctly balanced throughout the course of the token stream.</p>
|
||||
|
||||
column = <span class="hljs-property">@chunkColumn</span>
|
||||
<span class="hljs-keyword">if</span> lineCount > <span class="hljs-number">0</span>
|
||||
lines = string.split <span class="hljs-string">'\n'</span>
|
||||
column = last(lines).length
|
||||
[..., lastLine] = string.split <span class="hljs-string">'\n'</span>
|
||||
column = lastLine.length
|
||||
<span class="hljs-keyword">else</span>
|
||||
column += string.length
|
||||
|
||||
@@ -1375,12 +1400,13 @@ not specified, the length of <code>value</code> will be used.</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-53">¶</a>
|
||||
</div>
|
||||
<p>Peek at a tag in the current token stream.</p>
|
||||
<p>Peek at the last tag in the token stream.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">tag</span>: <span class="hljs-function"><span class="hljs-params">(index, tag)</span> -></span>
|
||||
(tok = last <span class="hljs-property">@tokens</span>, index) <span class="hljs-keyword">and</span> <span class="hljs-keyword">if</span> tag <span class="hljs-keyword">then</span> tok[<span class="hljs-number">0</span>] = tag <span class="hljs-keyword">else</span> tok[<span class="hljs-number">0</span>]</pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">tag</span>:<span class="hljs-function"> -></span>
|
||||
[..., token] = <span class="hljs-property">@tokens</span>
|
||||
token?[<span class="hljs-number">0</span>]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -1391,12 +1417,13 @@ not specified, the length of <code>value</code> will be used.</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-54">¶</a>
|
||||
</div>
|
||||
<p>Peek at a value in the current token stream.</p>
|
||||
<p>Peek at the last value in the token stream.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">value</span>: <span class="hljs-function"><span class="hljs-params">(index, val)</span> -></span>
|
||||
(tok = last <span class="hljs-property">@tokens</span>, index) <span class="hljs-keyword">and</span> <span class="hljs-keyword">if</span> val <span class="hljs-keyword">then</span> tok[<span class="hljs-number">1</span>] = val <span class="hljs-keyword">else</span> tok[<span class="hljs-number">1</span>]</pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">value</span>:<span class="hljs-function"> -></span>
|
||||
[..., token] = <span class="hljs-property">@tokens</span>
|
||||
token?[<span class="hljs-number">1</span>]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -1416,7 +1443,11 @@ not specified, the length of <code>value</code> will be used.</p>
|
||||
<span class="hljs-property">@tag</span>() <span class="hljs-keyword">in</span> [<span class="hljs-string">'\\'</span>, <span class="hljs-string">'.'</span>, <span class="hljs-string">'?.'</span>, <span class="hljs-string">'?::'</span>, <span class="hljs-string">'UNARY'</span>, <span class="hljs-string">'MATH'</span>, <span class="hljs-string">'UNARY_MATH'</span>, <span class="hljs-string">'+'</span>, <span class="hljs-string">'-'</span>, <span class="hljs-string">'YIELD'</span>,
|
||||
<span class="hljs-string">'**'</span>, <span class="hljs-string">'SHIFT'</span>, <span class="hljs-string">'RELATION'</span>, <span class="hljs-string">'COMPARE'</span>, <span class="hljs-string">'LOGIC'</span>, <span class="hljs-string">'THROW'</span>, <span class="hljs-string">'EXTENDS'</span>]
|
||||
|
||||
<span class="hljs-attribute">formatString</span>: <span class="hljs-function"><span class="hljs-params">(str)</span> -></span></pre></div></div>
|
||||
<span class="hljs-attribute">formatString</span>: <span class="hljs-function"><span class="hljs-params">(str)</span> -></span>
|
||||
str.replace STRING_OMIT, <span class="hljs-string">'$1'</span>
|
||||
|
||||
<span class="hljs-attribute">formatHeregex</span>: <span class="hljs-function"><span class="hljs-params">(str)</span> -></span>
|
||||
str.replace HEREGEX_OMIT, <span class="hljs-string">'$1$2'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -1427,15 +1458,24 @@ not specified, the length of <code>value</code> will be used.</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-56">¶</a>
|
||||
</div>
|
||||
<p>Ignore escaped backslashes and remove escaped newlines.</p>
|
||||
<p>Validates escapes in strings and regexes.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> str.replace <span class="hljs-regexp">/\\[^\S\n]*(\n|\\)\s*/g</span>, <span class="hljs-function"><span class="hljs-params">(escaped, character)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> character <span class="hljs-keyword">is</span> <span class="hljs-string">'\n'</span> <span class="hljs-keyword">then</span> <span class="hljs-string">''</span> <span class="hljs-keyword">else</span> escaped
|
||||
|
||||
<span class="hljs-attribute">formatHeregex</span>: <span class="hljs-function"><span class="hljs-params">(str)</span> -></span>
|
||||
str.replace(HEREGEX_OMIT, <span class="hljs-string">'$1$2'</span>).replace(MULTILINER, <span class="hljs-string">'\\n'</span>)</pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">validateEscapes</span>: <span class="hljs-function"><span class="hljs-params">(str, options = {})</span> -></span>
|
||||
match = INVALID_ESCAPE.exec str
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> match
|
||||
[[], before, octal, hex, unicode] = match
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> options.isRegex <span class="hljs-keyword">and</span> octal <span class="hljs-keyword">and</span> octal.charAt(<span class="hljs-number">0</span>) <span class="hljs-keyword">isnt</span> <span class="hljs-string">'0'</span>
|
||||
message =
|
||||
<span class="hljs-keyword">if</span> octal
|
||||
<span class="hljs-string">"octal escape sequences are not allowed"</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
<span class="hljs-string">"invalid escape sequence"</span>
|
||||
invalidEscape = <span class="hljs-string">"\\<span class="hljs-subst">#{octal <span class="hljs-keyword">or</span> hex <span class="hljs-keyword">or</span> unicode}</span>"</span>
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"<span class="hljs-subst">#{message}</span> <span class="hljs-subst">#{invalidEscape}</span>"</span>,
|
||||
<span class="hljs-attribute">offset</span>: (options.offsetInChunk ? <span class="hljs-number">0</span>) + match.index + before.length
|
||||
<span class="hljs-attribute">length</span>: invalidEscape.length</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -1446,12 +1486,20 @@ not specified, the length of <code>value</code> will be used.</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-57">¶</a>
|
||||
</div>
|
||||
<p>Constructs a string token by escaping quotes.</p>
|
||||
<p>Constructs a string or regex by escaping certain characters.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">makeString</span>: <span class="hljs-function"><span class="hljs-params">(body, quote)</span> -></span>
|
||||
<span class="hljs-keyword">return</span> quote + quote <span class="hljs-keyword">unless</span> body</pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">makeDelimitedLiteral</span>: <span class="hljs-function"><span class="hljs-params">(body, options = {})</span> -></span>
|
||||
body = <span class="hljs-string">'(?:)'</span> <span class="hljs-keyword">if</span> body <span class="hljs-keyword">is</span> <span class="hljs-string">''</span> <span class="hljs-keyword">and</span> options.delimiter <span class="hljs-keyword">is</span> <span class="hljs-string">'/'</span>
|
||||
regex = <span class="hljs-regexp">///
|
||||
(\\\\) <span class="hljs-comment"># escaped backslash</span>
|
||||
| (\\0(?=[1-7])) <span class="hljs-comment"># nul character mistaken as octal escape</span>
|
||||
| \\?(<span class="hljs-subst">#{options.delimiter}</span>) <span class="hljs-comment"># (possibly escaped) delimiter</span>
|
||||
| \\?(?: (\n)|(\r)|(\u2028)|(\u2029) ) <span class="hljs-comment"># (possibly escaped) newlines</span>
|
||||
| (\\.) <span class="hljs-comment"># other escapes</span>
|
||||
///</span>g
|
||||
body = body.replace regex, <span class="hljs-function"><span class="hljs-params">(match, backslash, nul, delimiter, lf, cr, ls, ps, other)</span> -></span> <span class="hljs-keyword">switch</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -1462,16 +1510,19 @@ not specified, the length of <code>value</code> will be used.</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-58">¶</a>
|
||||
</div>
|
||||
<p>Ignore escaped backslashes and unescape quotes.</p>
|
||||
<p>Ignore escaped backslashes.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> body = body.replace <span class="hljs-regexp">/// \\( <span class="hljs-subst">#{quote}</span> | \\ ) ///</span>g, <span class="hljs-function"><span class="hljs-params">(match, contents)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> contents <span class="hljs-keyword">is</span> quote <span class="hljs-keyword">then</span> contents <span class="hljs-keyword">else</span> match
|
||||
body = body.replace <span class="hljs-regexp">/// <span class="hljs-subst">#{quote}</span> ///</span>g, <span class="hljs-string">'\\$&'</span>
|
||||
<span class="hljs-keyword">if</span> match = OCTAL_ESCAPE.exec body
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"octal escape sequences are not allowed <span class="hljs-subst">#{match[<span class="hljs-number">2</span>]}</span>"</span>, match.index + match[<span class="hljs-number">1</span>].length + <span class="hljs-number">1</span>
|
||||
quote + body + quote</pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">when</span> backslash <span class="hljs-keyword">then</span> (<span class="hljs-keyword">if</span> options.double <span class="hljs-keyword">then</span> backslash + backslash <span class="hljs-keyword">else</span> backslash)
|
||||
<span class="hljs-keyword">when</span> nul <span class="hljs-keyword">then</span> <span class="hljs-string">'\\x00'</span>
|
||||
<span class="hljs-keyword">when</span> delimiter <span class="hljs-keyword">then</span> <span class="hljs-string">"\\<span class="hljs-subst">#{delimiter}</span>"</span>
|
||||
<span class="hljs-keyword">when</span> lf <span class="hljs-keyword">then</span> <span class="hljs-string">'\\n'</span>
|
||||
<span class="hljs-keyword">when</span> cr <span class="hljs-keyword">then</span> <span class="hljs-string">'\\r'</span>
|
||||
<span class="hljs-keyword">when</span> ls <span class="hljs-keyword">then</span> <span class="hljs-string">'\\u2028'</span>
|
||||
<span class="hljs-keyword">when</span> ps <span class="hljs-keyword">then</span> <span class="hljs-string">'\\u2029'</span>
|
||||
<span class="hljs-keyword">when</span> other <span class="hljs-keyword">then</span> (<span class="hljs-keyword">if</span> options.double <span class="hljs-keyword">then</span> <span class="hljs-string">"\\<span class="hljs-subst">#{other}</span>"</span> <span class="hljs-keyword">else</span> other)
|
||||
<span class="hljs-string">"<span class="hljs-subst">#{options.delimiter}</span><span class="hljs-subst">#{body}</span><span class="hljs-subst">#{options.delimiter}</span>"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -1482,11 +1533,19 @@ not specified, the length of <code>value</code> will be used.</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-59">¶</a>
|
||||
</div>
|
||||
<p>Throws a compiler error on the current position.</p>
|
||||
<p>Throws an error at either a given offset from the current chunk or at the
|
||||
location of a token (<code>token[2]</code>).</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">error</span>: <span class="hljs-function"><span class="hljs-params">(message, offset = <span class="hljs-number">0</span>)</span> -></span></pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">error</span>: <span class="hljs-function"><span class="hljs-params">(message, options = {})</span> -></span>
|
||||
location =
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-string">'first_line'</span> <span class="hljs-keyword">of</span> options
|
||||
options
|
||||
<span class="hljs-keyword">else</span>
|
||||
[first_line, first_column] = <span class="hljs-property">@getLineAndColumnFromChunk</span> options.offset ? <span class="hljs-number">0</span>
|
||||
{first_line, first_column, <span class="hljs-attribute">last_column</span>: first_column + (options.length ? <span class="hljs-number">1</span>) - <span class="hljs-number">1</span>}
|
||||
throwSyntaxError message, location</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -1497,14 +1556,10 @@ not specified, the length of <code>value</code> will be used.</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-60">¶</a>
|
||||
</div>
|
||||
<p>TODO: Are there some cases we could improve the error line number by
|
||||
passing the offset in the chunk where the error happened?</p>
|
||||
<h2 id="constants">Constants</h2>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> [first_line, first_column] = <span class="hljs-property">@getLineAndColumnFromChunk</span> offset
|
||||
throwSyntaxError message, {first_line, first_column}</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
@@ -1514,8 +1569,7 @@ passing the offset in the chunk where the error happened?</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-61">¶</a>
|
||||
</div>
|
||||
<h2 id="constants">Constants</h2>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
@@ -1527,18 +1581,6 @@ passing the offset in the chunk where the error happened?</p>
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-62">¶</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-63">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-63">¶</a>
|
||||
</div>
|
||||
<p>Keywords that CoffeeScript shares in common with JavaScript.</p>
|
||||
|
||||
</div>
|
||||
@@ -1554,11 +1596,11 @@ passing the offset in the chunk where the error happened?</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-64">
|
||||
<li id="section-63">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-64">¶</a>
|
||||
<a class="pilcrow" href="#section-63">¶</a>
|
||||
</div>
|
||||
<p>CoffeeScript-only keywords.</p>
|
||||
|
||||
@@ -1583,11 +1625,11 @@ COFFEE_KEYWORDS = COFFEE_KEYWORDS.concat COFFEE_ALIASES</pre></div></div>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-65">
|
||||
<li id="section-64">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-65">¶</a>
|
||||
<a class="pilcrow" href="#section-64">¶</a>
|
||||
</div>
|
||||
<p>The list of keywords that are reserved by JavaScript, but not used, or are
|
||||
used by CoffeeScript internally. We throw an error when these are encountered,
|
||||
@@ -1606,11 +1648,11 @@ STRICT_PROSCRIBED = [<span class="hljs-string">'arguments'</span>, <span class="
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-66">
|
||||
<li id="section-65">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-66">¶</a>
|
||||
<a class="pilcrow" href="#section-65">¶</a>
|
||||
</div>
|
||||
<p>The superset of both JavaScript keywords and reserved words, none of which may
|
||||
be used as identifiers or properties.</p>
|
||||
@@ -1619,17 +1661,17 @@ be used as identifiers or properties.</p>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>JS_FORBIDDEN = JS_KEYWORDS.concat(RESERVED).concat(STRICT_PROSCRIBED)
|
||||
|
||||
exports.RESERVED = RESERVED.concat(JS_KEYWORDS).concat(COFFEE_KEYWORDS).concat(STRICT_PROSCRIBED)
|
||||
exports.STRICT_PROSCRIBED = STRICT_PROSCRIBED</pre></div></div>
|
||||
<span class="hljs-built_in">exports</span>.RESERVED = RESERVED.concat(JS_KEYWORDS).concat(COFFEE_KEYWORDS).concat(STRICT_PROSCRIBED)
|
||||
<span class="hljs-built_in">exports</span>.STRICT_PROSCRIBED = STRICT_PROSCRIBED</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-67">
|
||||
<li id="section-66">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-67">¶</a>
|
||||
<a class="pilcrow" href="#section-66">¶</a>
|
||||
</div>
|
||||
<p>The character code of the nasty Microsoft madness otherwise known as the BOM.</p>
|
||||
|
||||
@@ -1640,11 +1682,11 @@ exports.STRICT_PROSCRIBED = STRICT_PROSCRIBED</pre></div></div>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-68">
|
||||
<li id="section-67">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-68">¶</a>
|
||||
<a class="pilcrow" href="#section-67">¶</a>
|
||||
</div>
|
||||
<p>Token matching regexes.</p>
|
||||
|
||||
@@ -1686,11 +1728,11 @@ JSTOKEN = <span class="hljs-regexp">/^`[^\\`]*(?:\\.[^\\`]*)*`/</span></pre><
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-69">
|
||||
<li id="section-68">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-69">¶</a>
|
||||
<a class="pilcrow" href="#section-68">¶</a>
|
||||
</div>
|
||||
<p>String-matching-regexes.</p>
|
||||
|
||||
@@ -1703,30 +1745,34 @@ STRING_DOUBLE = <span class="hljs-regexp">/// ^(?: [^\\"<span class="hljs-comme
|
||||
HEREDOC_SINGLE = ///</span> ^(?: [^\\<span class="hljs-string">'] | \\[\s\S] | '</span>(?!<span class="hljs-string">''</span>) )* <span class="hljs-regexp">///
|
||||
HEREDOC_DOUBLE = ///</span> ^(?: [^\\<span class="hljs-string">"#] | \\[\s\S] | "</span>(?!<span class="hljs-string">""</span>) | \<span class="hljs-comment">#(?!\{) )* ///</span>
|
||||
|
||||
STRING_OMIT = <span class="hljs-regexp">/\s*\n\s*/g</span>
|
||||
HEREDOC_INDENT = <span class="hljs-regexp">/\n+([^\n\S]*)(?=\S)/g</span></pre></div></div>
|
||||
STRING_OMIT = <span class="hljs-regexp">///
|
||||
((?:\\\\)+) <span class="hljs-comment"># consume (and preserve) an even number of backslashes</span>
|
||||
| \\[^\S\n]*\n\s* <span class="hljs-comment"># remove escaped newlines</span>
|
||||
///</span>g
|
||||
SIMPLE_STRING_OMIT = <span class="hljs-regexp">/\s*\n\s*/g</span>
|
||||
HEREDOC_INDENT = <span class="hljs-regexp">/\n+([^\n\S]*)(?=\S)/g</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-70">
|
||||
<li id="section-69">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-70">¶</a>
|
||||
<a class="pilcrow" href="#section-69">¶</a>
|
||||
</div>
|
||||
<p>Regex-matching-regexes.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>REGEX = <span class="hljs-regexp">/// ^
|
||||
/ (?!/) (
|
||||
/ (?!/) ((
|
||||
?: [^ [ / \n \\ ] <span class="hljs-comment"># every other thing</span>
|
||||
| \\. <span class="hljs-comment"># anything (but newlines) escaped</span>
|
||||
| \\[^\n] <span class="hljs-comment"># anything but newlines escaped</span>
|
||||
| \[ <span class="hljs-comment"># character class</span>
|
||||
(?: \\. | [^ \] \n \\ ] )*
|
||||
]
|
||||
)* (/)?
|
||||
(?: \\[^\n] | [^ \] \n \\ ] )*
|
||||
\]
|
||||
)*) (/)?
|
||||
///</span>
|
||||
|
||||
REGEX_FLAGS = <span class="hljs-regexp">/^\w*/</span>
|
||||
@@ -1736,7 +1782,7 @@ HEREGEX = <span class="hljs-regexp">/// ^(?: [^\\/<span class="hljs-comment
|
||||
|
||||
HEREGEX_OMIT = ///</span>
|
||||
((?:\\\\)+) <span class="hljs-comment"># consume (and preserve) an even number of backslashes</span>
|
||||
| \\(\s|/) <span class="hljs-comment"># preserve escaped whitespace and "de-escape" slashes</span>
|
||||
| \\(\s) <span class="hljs-comment"># preserve escaped whitespace</span>
|
||||
| \s+(?:<span class="hljs-comment">#.*)? # remove whitespace and comments</span>
|
||||
<span class="hljs-regexp">///g
|
||||
|
||||
@@ -1747,23 +1793,28 @@ POSSIBLY_DIVISION = <span class="hljs-regexp">/// ^ /=?\s ///</span></pre></di
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-71">
|
||||
<li id="section-70">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-71">¶</a>
|
||||
<a class="pilcrow" href="#section-70">¶</a>
|
||||
</div>
|
||||
<p>Other regexes.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>MULTILINER = <span class="hljs-regexp">/\n/g</span>
|
||||
|
||||
HERECOMMENT_ILLEGAL = <span class="hljs-regexp">/\*\//</span>
|
||||
<div class="content"><div class='highlight'><pre>HERECOMMENT_ILLEGAL = <span class="hljs-regexp">/\*\//</span>
|
||||
|
||||
LINE_CONTINUER = <span class="hljs-regexp">/// ^ \s* (?: , | \??\.(?![.\d]) | :: ) ///</span>
|
||||
|
||||
OCTAL_ESCAPE = <span class="hljs-regexp">/// ^ ((?: \\. | [^\\] )*) (\\ (?: 0[0-7] | [1-7] )) ///</span>
|
||||
INVALID_ESCAPE = <span class="hljs-regexp">///
|
||||
( (?:^|[^\\]) (?:\\\\)* ) <span class="hljs-comment"># make sure the escape isn’t escaped</span>
|
||||
\\ (
|
||||
?: (0[0-7]|[1-7]) <span class="hljs-comment"># octal escape</span>
|
||||
| (x(?![\da-fA-F]{2}).{0,2}) <span class="hljs-comment"># hex escape</span>
|
||||
| (u(?![\da-fA-F]{4}).{0,4}) <span class="hljs-comment"># unicode escape</span>
|
||||
)
|
||||
///</span>
|
||||
|
||||
LEADING_BLANK_LINE = <span class="hljs-regexp">/^[^\n\S]*\n/</span>
|
||||
TRAILING_BLANK_LINE = <span class="hljs-regexp">/\n[^\n\S]*$/</span>
|
||||
@@ -1773,11 +1824,11 @@ TRAILING_SPACES = <span class="hljs-regexp">/\s+$/</span></pre></div></div>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-72">
|
||||
<li id="section-71">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-72">¶</a>
|
||||
<a class="pilcrow" href="#section-71">¶</a>
|
||||
</div>
|
||||
<p>Compound assignment tokens.</p>
|
||||
|
||||
@@ -1791,11 +1842,11 @@ TRAILING_SPACES = <span class="hljs-regexp">/\s+$/</span></pre></div></div>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-73">
|
||||
<li id="section-72">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-73">¶</a>
|
||||
<a class="pilcrow" href="#section-72">¶</a>
|
||||
</div>
|
||||
<p>Unary tokens.</p>
|
||||
|
||||
@@ -1808,11 +1859,11 @@ UNARY_MATH = [<span class="hljs-string">'!'</span>, <span class="hljs-string">'~
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-74">
|
||||
<li id="section-73">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-74">¶</a>
|
||||
<a class="pilcrow" href="#section-73">¶</a>
|
||||
</div>
|
||||
<p>Logical tokens.</p>
|
||||
|
||||
@@ -1823,11 +1874,11 @@ UNARY_MATH = [<span class="hljs-string">'!'</span>, <span class="hljs-string">'~
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-75">
|
||||
<li id="section-74">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-75">¶</a>
|
||||
<a class="pilcrow" href="#section-74">¶</a>
|
||||
</div>
|
||||
<p>Bit-shifting tokens.</p>
|
||||
|
||||
@@ -1838,11 +1889,11 @@ UNARY_MATH = [<span class="hljs-string">'!'</span>, <span class="hljs-string">'~
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-76">
|
||||
<li id="section-75">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-76">¶</a>
|
||||
<a class="pilcrow" href="#section-75">¶</a>
|
||||
</div>
|
||||
<p>Comparison tokens.</p>
|
||||
|
||||
@@ -1853,11 +1904,11 @@ UNARY_MATH = [<span class="hljs-string">'!'</span>, <span class="hljs-string">'~
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-77">
|
||||
<li id="section-76">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-77">¶</a>
|
||||
<a class="pilcrow" href="#section-76">¶</a>
|
||||
</div>
|
||||
<p>Mathematical tokens.</p>
|
||||
|
||||
@@ -1868,11 +1919,11 @@ UNARY_MATH = [<span class="hljs-string">'!'</span>, <span class="hljs-string">'~
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-78">
|
||||
<li id="section-77">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-78">¶</a>
|
||||
<a class="pilcrow" href="#section-77">¶</a>
|
||||
</div>
|
||||
<p>Relational tokens that are negatable with <code>not</code> prefix.</p>
|
||||
|
||||
@@ -1883,11 +1934,11 @@ UNARY_MATH = [<span class="hljs-string">'!'</span>, <span class="hljs-string">'~
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-79">
|
||||
<li id="section-78">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-79">¶</a>
|
||||
<a class="pilcrow" href="#section-78">¶</a>
|
||||
</div>
|
||||
<p>Boolean tokens.</p>
|
||||
|
||||
@@ -1898,11 +1949,11 @@ UNARY_MATH = [<span class="hljs-string">'!'</span>, <span class="hljs-string">'~
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-80">
|
||||
<li id="section-79">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-80">¶</a>
|
||||
<a class="pilcrow" href="#section-79">¶</a>
|
||||
</div>
|
||||
<p>Tokens which could legitimately be invoked or indexed. An opening
|
||||
parentheses or bracket following these tokens will be recorded as the start
|
||||
@@ -1911,16 +1962,19 @@ of a function invocation or indexing operation.</p>
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>CALLABLE = [<span class="hljs-string">'IDENTIFIER'</span>, <span class="hljs-string">')'</span>, <span class="hljs-string">']'</span>, <span class="hljs-string">'?'</span>, <span class="hljs-string">'@'</span>, <span class="hljs-string">'THIS'</span>, <span class="hljs-string">'SUPER'</span>]
|
||||
INDEXABLE = CALLABLE.concat [<span class="hljs-string">'NUMBER'</span>, <span class="hljs-string">'STRING'</span>, <span class="hljs-string">'REGEX'</span>, <span class="hljs-string">'BOOL'</span>, <span class="hljs-string">'NULL'</span>, <span class="hljs-string">'UNDEFINED'</span>, <span class="hljs-string">'}'</span>, <span class="hljs-string">'::'</span>]</pre></div></div>
|
||||
INDEXABLE = CALLABLE.concat [
|
||||
<span class="hljs-string">'NUMBER'</span>, <span class="hljs-string">'STRING'</span>, <span class="hljs-string">'STRING_END'</span>, <span class="hljs-string">'REGEX'</span>, <span class="hljs-string">'REGEX_END'</span>
|
||||
<span class="hljs-string">'BOOL'</span>, <span class="hljs-string">'NULL'</span>, <span class="hljs-string">'UNDEFINED'</span>, <span class="hljs-string">'}'</span>, <span class="hljs-string">'::'</span>
|
||||
]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-81">
|
||||
<li id="section-80">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-81">¶</a>
|
||||
<a class="pilcrow" href="#section-80">¶</a>
|
||||
</div>
|
||||
<p>Tokens which a regular expression will never immediately follow (except spaced
|
||||
CALLABLEs in some cases), but which a division operator can.</p>
|
||||
@@ -1933,11 +1987,11 @@ CALLABLEs in some cases), but which a division operator can.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-82">
|
||||
<li id="section-81">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-82">¶</a>
|
||||
<a class="pilcrow" href="#section-81">¶</a>
|
||||
</div>
|
||||
<p>Tokens that, when immediately preceding a <code>WHEN</code>, indicate that the <code>WHEN</code>
|
||||
occurs at the start of a line. We disambiguate these from trailing whens to
|
||||
@@ -1950,11 +2004,11 @@ avoid an ambiguity in the grammar.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-83">
|
||||
<li id="section-82">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-83">¶</a>
|
||||
<a class="pilcrow" href="#section-82">¶</a>
|
||||
</div>
|
||||
<p>Additional indent in front of these is ignored.</p>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -138,7 +138,7 @@ option) list, and all subsequent arguments are left unparsed.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.OptionParser = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">OptionParser</span></span></pre></div></div>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.OptionParser = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">OptionParser</span></span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
0
documentation/docs/public/fonts/aller-bold.eot
Executable file → Normal file
0
documentation/docs/public/fonts/aller-bold.eot
Executable file → Normal file
0
documentation/docs/public/fonts/aller-bold.ttf
Executable file → Normal file
0
documentation/docs/public/fonts/aller-bold.ttf
Executable file → Normal file
0
documentation/docs/public/fonts/aller-bold.woff
Executable file → Normal file
0
documentation/docs/public/fonts/aller-bold.woff
Executable file → Normal file
0
documentation/docs/public/fonts/aller-light.eot
Executable file → Normal file
0
documentation/docs/public/fonts/aller-light.eot
Executable file → Normal file
0
documentation/docs/public/fonts/aller-light.ttf
Executable file → Normal file
0
documentation/docs/public/fonts/aller-light.ttf
Executable file → Normal file
0
documentation/docs/public/fonts/aller-light.woff
Executable file → Normal file
0
documentation/docs/public/fonts/aller-light.woff
Executable file → Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
documentation/docs/public/fonts/roboto-black.eot
Executable file
BIN
documentation/docs/public/fonts/roboto-black.eot
Executable file
Binary file not shown.
BIN
documentation/docs/public/fonts/roboto-black.ttf
Executable file
BIN
documentation/docs/public/fonts/roboto-black.ttf
Executable file
Binary file not shown.
BIN
documentation/docs/public/fonts/roboto-black.woff
Executable file
BIN
documentation/docs/public/fonts/roboto-black.woff
Executable file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user