mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
namespacing CoffeeScript in the browser, and sniffing the 'require' function instead of the 'exports' object
This commit is contained in:
parent
ff1fd97924
commit
2f6b69b580
12 changed files with 26 additions and 26 deletions
|
@ -854,7 +854,7 @@ print reverse 'tpircseeffoc'</textarea>
|
|||
var source = document.getElementById('repl_source').value;
|
||||
var js = '';
|
||||
try {
|
||||
js = compile(source, {no_wrap: true});
|
||||
js = CoffeeScript.compile(source, {no_wrap: true});
|
||||
} catch(error) {
|
||||
alert(error);
|
||||
}
|
||||
|
|
|
@ -1725,7 +1725,7 @@ html <span class="Keyword">=</span> <span class="String"><span class="String">&q
|
|||
var source = document.getElementById('repl_source').value;
|
||||
var js = '';
|
||||
try {
|
||||
js = compile(source, {no_wrap: true});
|
||||
js = CoffeeScript.compile(source, {no_wrap: true});
|
||||
} catch(error) {
|
||||
alert(error);
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
(function(){
|
||||
var lexer, parser, path;
|
||||
var exports, lexer, parser, path;
|
||||
// Set up for both the browser and the server.
|
||||
if ((typeof process !== "undefined" && process !== null)) {
|
||||
if ((typeof require !== "undefined" && require !== null)) {
|
||||
process.mixin(require('nodes'));
|
||||
path = require('path');
|
||||
lexer = new (require('lexer').Lexer)();
|
||||
parser = require('parser').parser;
|
||||
} else {
|
||||
this.exports = this;
|
||||
exports = (this.CoffeeScript = {});
|
||||
lexer = new Lexer();
|
||||
parser = exports.parser;
|
||||
parser = this.parser;
|
||||
}
|
||||
// Thin wrapper for Jison compatibility around the real lexer.
|
||||
parser.lexer = {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
(function(){
|
||||
var ACCESSORS, ASSIGNMENT, BEFORE_WHEN, CALLABLE, CODE, COMMENT, COMMENT_CLEANER, HEREDOC, HEREDOC_INDENT, IDENTIFIER, JS, JS_CLEANER, KEYWORDS, LAST_DENT, LAST_DENTS, MULTILINER, MULTI_DENT, NOT_REGEX, NO_NEWLINE, NUMBER, OPERATOR, REGEX, RESERVED, Rewriter, STRING, STRING_NEWLINES, WHITESPACE, lex;
|
||||
if ((typeof process !== "undefined" && process !== null)) {
|
||||
var ACCESSORS, ASSIGNMENT, BEFORE_WHEN, CALLABLE, CODE, COMMENT, COMMENT_CLEANER, HEREDOC, HEREDOC_INDENT, IDENTIFIER, JS, JS_CLEANER, KEYWORDS, LAST_DENT, LAST_DENTS, MULTILINER, MULTI_DENT, NOT_REGEX, NO_NEWLINE, NUMBER, OPERATOR, REGEX, RESERVED, Rewriter, STRING, STRING_NEWLINES, WHITESPACE, exports, lex;
|
||||
if ((typeof require !== "undefined" && require !== null)) {
|
||||
Rewriter = require('./rewriter').Rewriter;
|
||||
} else {
|
||||
this.exports = this;
|
||||
exports = this;
|
||||
Rewriter = this.Rewriter;
|
||||
}
|
||||
// The lexer reads a stream of CoffeeScript and divvys it up into tagged
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(function(){
|
||||
var AccessorNode, ArrayNode, AssignNode, CallNode, ClosureNode, CodeNode, CommentNode, ExistenceNode, Expressions, ExtendsNode, ForNode, IDENTIFIER, IfNode, IndexNode, LiteralNode, Node, ObjectNode, OpNode, ParentheticalNode, PushNode, RangeNode, ReturnNode, SliceNode, SplatNode, TAB, TRAILING_WHITESPACE, ThisNode, ThrowNode, TryNode, ValueNode, WhileNode, compact, del, flatten, inherit, merge, statement;
|
||||
var AccessorNode, ArrayNode, AssignNode, CallNode, ClosureNode, CodeNode, CommentNode, ExistenceNode, Expressions, ExtendsNode, ForNode, IDENTIFIER, IfNode, IndexNode, LiteralNode, Node, ObjectNode, OpNode, ParentheticalNode, PushNode, RangeNode, ReturnNode, SliceNode, SplatNode, TAB, TRAILING_WHITESPACE, ThisNode, ThrowNode, TryNode, ValueNode, WhileNode, compact, del, exports, flatten, inherit, merge, statement;
|
||||
var __hasProp = Object.prototype.hasOwnProperty;
|
||||
(typeof process !== "undefined" && process !== null) ? process.mixin(require('scope')) : (this.exports = this);
|
||||
(typeof require !== "undefined" && require !== null) ? process.mixin(require('scope')) : (exports = this);
|
||||
// Some helper functions
|
||||
// Tabs are two spaces for pretty printing.
|
||||
TAB = ' ';
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
(function(){
|
||||
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_START, EXPRESSION_TAIL, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, INVERSES, SINGLE_CLOSERS, SINGLE_LINERS, _a, _b, _c, _d, _e, _f, _g, _h, pair, re;
|
||||
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_START, EXPRESSION_TAIL, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, INVERSES, SINGLE_CLOSERS, SINGLE_LINERS, _a, _b, _c, _d, _e, _f, _g, _h, exports, pair, re;
|
||||
var __hasProp = Object.prototype.hasOwnProperty;
|
||||
if (!((typeof process !== "undefined" && process !== null))) {
|
||||
this.exports = this;
|
||||
if (!((typeof require !== "undefined" && require !== null))) {
|
||||
exports = this;
|
||||
}
|
||||
// In order to keep the grammar simple, the stream of tokens that the Lexer
|
||||
// emits is rewritten by the Rewriter, smoothing out ambiguities, mis-nested
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
(function(){
|
||||
var Scope;
|
||||
var Scope, exports;
|
||||
var __hasProp = Object.prototype.hasOwnProperty;
|
||||
if (!((typeof process !== "undefined" && process !== null))) {
|
||||
this.exports = this;
|
||||
if (!((typeof require !== "undefined" && require !== null))) {
|
||||
exports = this;
|
||||
}
|
||||
// Scope objects form a tree corresponding to the shape of the function
|
||||
// definitions present in the script. They provide lexical scope, to determine
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
# Set up for both the browser and the server.
|
||||
if process?
|
||||
if require?
|
||||
process.mixin require 'nodes'
|
||||
path: require 'path'
|
||||
lexer: new (require('lexer').Lexer)()
|
||||
parser: require('parser').parser
|
||||
else
|
||||
this.exports: this
|
||||
exports: this.CoffeeScript: {}
|
||||
lexer: new Lexer()
|
||||
parser: exports.parser
|
||||
parser: this.parser
|
||||
|
||||
# Thin wrapper for Jison compatibility around the real lexer.
|
||||
parser.lexer: {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
if process?
|
||||
if require?
|
||||
Rewriter: require('./rewriter').Rewriter
|
||||
else
|
||||
this.exports: this
|
||||
exports: this
|
||||
Rewriter: this.Rewriter
|
||||
|
||||
# The lexer reads a stream of CoffeeScript and divvys it up into tagged
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
if process?
|
||||
if require?
|
||||
process.mixin require 'scope'
|
||||
else
|
||||
this.exports: this
|
||||
exports: this
|
||||
|
||||
# Some helper functions
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
this.exports: this unless process?
|
||||
exports: this unless require?
|
||||
|
||||
# In order to keep the grammar simple, the stream of tokens that the Lexer
|
||||
# emits is rewritten by the Rewriter, smoothing out ambiguities, mis-nested
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
this.exports: this unless process?
|
||||
exports: this unless require?
|
||||
|
||||
# Scope objects form a tree corresponding to the shape of the function
|
||||
# definitions present in the script. They provide lexical scope, to determine
|
||||
|
|
Loading…
Add table
Reference in a new issue