CoffeeScript = require './coffee-script'
+
+CoffeeScript = require './coffee-script'
CoffeeScript.require = require
compile = CoffeeScript.compile
@@ -168,7 +169,7 @@ compile = CoffeeScript.compile
diff --git a/documentation/docs/browser.html b/documentation/docs/browser.html index 8b759611..8877634f 100644 --- a/documentation/docs/browser.html +++ b/documentation/docs/browser.html @@ -120,7 +120,8 @@ We add support for loading remote Coffee scripts via XHR, and -
CoffeeScript = require './coffee-script'
+
+CoffeeScript = require './coffee-script'
CoffeeScript.require = require
compile = CoffeeScript.compile
@@ -168,7 +169,7 @@ compile = CoffeeScript.compile
If we're not in a browser environment, we're finished with the public API.
+If we’re not in a browser environment, we’re finished with the public API.
@@ -183,8 +184,8 @@ compile = CoffeeScript.compile -Include source maps where possible. If we've got a base64 encoder, a -JSON serializer, and tools for escaping unicode characters, we're good to go. +
Include source maps where possible. If we’ve got a base64 encoder, a +JSON serializer, and tools for escaping unicode characters, we’re good to go. Ported from https://developer.mozilla.org/en-US/docs/DOM/window.btoa
diff --git a/documentation/docs/cake.html b/documentation/docs/cake.html index d129a301..e92563d9 100644 --- a/documentation/docs/cake.html +++ b/documentation/docs/cake.html @@ -118,8 +118,20 @@ for CoffeeScript. You define tasks with names and descriptions in a Cakefile, and can call them from the command line, or invoke them from other tasks.Running cake
with no arguments will print out a list of all the tasks in the
-current directory's Cakefile.
External dependencies.
+current directory’s Cakefile. + + + + + + +External dependencies.
CoffeeScript.register()
Keep track of the list of defined tasks, the accepted options, and so on.
@@ -150,11 +177,11 @@ oparse = nullDefine a Cake task with a short name, an optional sentence description, and the function to run as the action itself.
@@ -183,11 +210,11 @@ and the function to run as the action itself. -Define an option that the Cakefile accepts. The parsed options hash, containing all of the command-line options passed, will be made available @@ -201,11 +228,11 @@ as the first argument to the action.
-Invoke another task in the current Cakefile.
@@ -218,14 +245,14 @@ as the first argument to the action. -Run cake
. Executes all of the tasks you pass, in order. Note that Node's
-asynchrony may cause tasks to execute in a different order than you'd expect.
+
Run cake
. Executes all of the tasks you pass, in order. Note that Node’s
+asynchrony may cause tasks to execute in a different order than you’d expect.
If no tasks are passed, print the help screen. Keep a reference to the
original directory name, when running Cake tasks from subdirectories.
Display the list of Cake tasks in a format similar to rake -T
Print an error and exit when attempting to use an invalid task/option.
@@ -291,11 +318,11 @@ original directory name, when running Cake tasks from subdirectories. -When cake
is invoked, search in the current and all parent directories
to find the relevant Cakefile.
fs = require 'fs'
+
+fs = require 'fs'
vm = require 'vm'
path = require 'path'
{Lexer} = require './lexer'
@@ -466,7 +467,27 @@ The CoffeeScript REPL uses this to run the input.
else
vm.runInContext js, sandbox
-exports.register = -> require './register'
+exports.register = -> require './register'
+
+
+
+
+
Throw error with deprecation warning when depending upon implicit require.extensions
registration
if require.extensions
+ for ext in @FILE_EXTENSIONS
+ require.extensions[ext] ?= ->
+ throw new Error """
+ Use CoffeeScript.register() or require the coffee-script/register module to require #{ext} files.
+ """
exports._compileFile = (filename, sourceMap = no) ->
raw = fs.readFileSync filename, 'utf8'
@@ -479,11 +500,11 @@ The CoffeeScript REPL uses this to run the input.
-
As the filename and code of a dynamically loaded file will be different from the original file compiled with CoffeeScript.run, add that @@ -498,11 +519,11 @@ information to error so it can be pretty-printed later.
-Instantiate a Lexer for our use here.
@@ -513,15 +534,15 @@ information to error so it can be pretty-printed later. -Make all the AST nodes visible to the parser.
@@ -559,13 +580,13 @@ directly as a "Jison lexer". -Disregard Jison's message, it contains redundant line numer information. +
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.
@@ -599,11 +620,11 @@ the error is caused by a generated token which might refer to its origin. -The second argument has a loc
property, which should have the location
data for this token. Unfortunately, Jison seems to send an outdated loc
@@ -617,11 +638,11 @@ from the lexer.
Based on http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js Modified to handle sourceMap
@@ -649,11 +670,11 @@ Modified to handle sourceMap -Check for a sourceMap position
@@ -694,11 +715,11 @@ Modified to handle sourceMap -Map of filenames -> sourceMap object.
@@ -709,11 +730,11 @@ Modified to handle sourceMap -Generates the source map for a coffee file and stores it in the local cache variable.
@@ -728,11 +749,11 @@ Modified to handle sourceMap -Based on michaelficarra/CoffeeScriptRedux NodeJS / V8 have no support for transforming positions in stack traces using @@ -751,7 +772,7 @@ positions.
break if frame.getFunction() is exports.run " at #{formatSourcePosition frame, getSourceMapping}" - "#{err.name}: #{err.message ? ''}\n#{frames.join '\n'}\n".js
files or printed to stdout
or recompiled every time the source is saved,
printed as a token stream or as the syntax tree, or launch an
interactive REPL.
-External dependencies.
+ +External dependencies.
Allow CoffeeScript to emit Node.js events.
@@ -156,11 +168,11 @@ useWinPathSep = path.sep is +The help banner that is printed in conjunction with -h
/--help
.
Run coffee
by parsing passed options and determining what action to take.
Many flags cause us to divert before compiling anything. Flags passed after
@@ -246,15 +258,15 @@ Many flags cause us to divert before compiling anything. Flags passed after
-
Make the REPL CLI use the global context so as to (a) be consistent with the +
Make the REPL CLI use the global context so as to (a) be consistent with the
node
REPL CLI and, therefore, (b) make packages that modify native prototypes
-(such as 'colors' and 'sugar') work as expected.
Compile a single source script, containing the given code, according to the
requested options. If evaluating the script directly sets __filename
,
-__dirname
and module.filename
to be correct relative to the script's path.
__dirname
and module.filename
to be correct relative to the script’s path.
__filename
- Attach the appropriate listeners to compile scripts incoming over stdin, and write them back to stdout.
@@ -418,11 +445,11 @@ and write them back to stdout. -If all of the source files are done being read, concatenate and compile them together.
@@ -440,11 +467,11 @@ them together. -Watch a source CoffeeScript file using fs.watch
, recompiling it every
time the file is updated. May be used in combination with other options,
@@ -500,11 +527,11 @@ such as --print
.
Watch a directory of files for new additions.
@@ -551,11 +578,11 @@ such as--print
.
- Remove a file from our source list, and source code cache. Optionally remove the compiled JS version as well.
@@ -580,11 +607,11 @@ the compiled JS version as well. -Get the corresponding output JavaScript path for a source file.
@@ -604,11 +631,11 @@ the compiled JS version as well. -Write out a JavaScript source file with the compiled code. By default, files
are written out in cwd
as .js
files with the same name, but the output
@@ -628,45 +655,31 @@ same directory as the .js
file.
Convenience for cleaner setTimeouts.
- -wait = (milliseconds, func) -> setTimeout func, milliseconds
When watching scripts, it's useful to log changes with the timestamp.
+Convenience for cleaner setTimeouts.
timeLog = (message) ->
- console.log "#{(new Date).toLocaleTimeString()} - #{message}"
wait = (milliseconds, func) -> setTimeout func, milliseconds
.js
file.
+ When watching scripts, it’s useful to log changes with the timestamp.
+ +timeLog = (message) ->
+ console.log "#{(new Date).toLocaleTimeString()} - #{message}"
Pretty-print a stream of tokens, sans location data.
.js
file.
Use the OptionParser module to extract all options from
process.argv
that are specified in SWITCHES
.
.js
file.
- The compile-time options to pass to the CoffeeScript compiler.
@@ -751,11 +780,11 @@ same directory as the.js
file.
- Start up a new Node.js instance with the arguments in --nodejs
passed to
the node
binary, preserving the other options.
node
binary, preserving the other options.
- Print the --help
usage message and exit. Deprecated switches are not
shown.
Print the --version
message and exit.
{Parser} = require 'jison'
lib/parser.js
.
- The only dependency is on the Jison.Parser.
{Parser} = require 'jison'
lib/parser.js
.
- Since we're going to be wrapped in a function by Jison in any case, if our +
Since we’re going to be wrapped in a function by Jison in any case, if our action immediately returns a value, we can optimize by removing the function wrapper and just returning the value directly.
@@ -166,11 +190,11 @@ wrapper and just returning the value directly. -Our handy DSL for Jison grammar generation, thanks to Tim Caswell. For every rule in the grammar, @@ -189,13 +213,13 @@ previous nonterminal.
-Returns a function which adds location data to the first parameter passed in, and returns the parameter. If the parameter is not a node, it will @@ -231,11 +255,11 @@ just be passed through unaffected.
-In all of the rules that follow, you’ll see the name of the nonterminal as +the key to a list of alternative matches. With each match’s action, the dollar-sign variables are provided by Jison as references to the value of their numeric position, so in this rule:
-"Expression UNLESS Expression"
+"Expression UNLESS Expression"
$1
would be the value of the first Expression
, $2
would be the token
for the UNLESS
terminal, and $3
would be the value of the second
Expression
.
@@ -266,11 +302,11 @@ for the UNLESS
terminal, and $3
would be the value of
-
+
The Root is the top-level node in the syntax tree. Since we parse bottom-up,
all parsing must end here.
@@ -285,11 +321,11 @@ all parsing must end here.
-
+
Any list of statements and expressions, separated by line breaks or semicolons.
@@ -304,11 +340,11 @@ all parsing must end here.
-
+
Block and statements, which make up a line in a body.
@@ -322,11 +358,11 @@ all parsing must end here.
-
+
Pure statements which cannot be expressions.
@@ -341,14 +377,14 @@ all parsing must end here.
-
+
All the different types of expressions in our language. The basic unit of
-CoffeeScript is the Expression -- everything that can be an expression
+CoffeeScript is the Expression — everything that can be an expression
is one. Blocks serve as the building blocks of many other rules, making
them somewhat circular.
@@ -372,11 +408,11 @@ them somewhat circular.
-
+
An indented block of expressions. Note that the Rewriter
will convert some postfix forms into blocks for us, by adjusting the
@@ -392,11 +428,11 @@ token stream.
-
+
A literal identifier, a variable name or property.
@@ -409,11 +445,11 @@ token stream.
-
+
Alphanumerics are separated from the other Literal matchers because
they can also serve as keys in object literals.
@@ -428,11 +464,11 @@ they can also serve as keys in object literals.
-
+
All of our immediate values. Generally these can be passed straight
through and printed to JavaScript.
@@ -452,11 +488,11 @@ through and printed to JavaScript.
-
+
Assignment of a variable, property, or index to a value.
@@ -471,11 +507,11 @@ through and printed to JavaScript.
-
+
Assignment when it happens within an object literal. The difference from
the ordinary Assign is that these allow numbers and strings as keys.
@@ -499,11 +535,11 @@ the ordinary Assign is that these allow numbers and strings as
-
+
A return statement from a function body.
@@ -517,11 +553,11 @@ the ordinary Assign is that these allow numbers and strings as
-
+
A block comment.
@@ -534,13 +570,13 @@ the ordinary Assign is that these allow numbers and strings as
-
+
- The Code node is the function literal. It's defined by an indented block
+
The Code node is the function literal. It’s defined by an indented block
of Block preceded by a function arrow, with an optional parameter
list.
@@ -554,11 +590,11 @@ list.
-
+
CoffeeScript has two different symbols for functions. ->
is for ordinary
functions, and =>
is for functions bound to the current value of this.
@@ -573,11 +609,11 @@ functions, and =>
is for functions bound to the current value of
-
+
An optional, trailing comma.
@@ -591,11 +627,11 @@ functions, and =>
is for functions bound to the current value of
-
+
The list of parameters that a function accepts can be of any length.
@@ -612,11 +648,11 @@ functions, and =>
is for functions bound to the current value of
-
+
A single parameter in a function definition can be ordinary, or a splat
that hoovers up the remaining arguments.
@@ -633,11 +669,11 @@ that hoovers up the remaining arguments.
-
+
Function Parameters
@@ -653,11 +689,11 @@ that hoovers up the remaining arguments.
-
+
A splat that occurs outside of a parameter list.
@@ -670,11 +706,11 @@ that hoovers up the remaining arguments.
-
+
Variables and properties that can be assigned to.
@@ -690,11 +726,11 @@ that hoovers up the remaining arguments.
-
+
Everything that can be assigned to.
@@ -709,13 +745,13 @@ that hoovers up the remaining arguments.
-
+
@@ -731,11 +767,11 @@ as functions, indexed into, named as a class, etc.
-
+
The general group of accessors into an object, by property, by prototype
or by array index or slice.
@@ -754,11 +790,11 @@ or by array index or slice.
-
+
Indexing into an object or array using bracket notation.
@@ -777,11 +813,11 @@ or by array index or slice.
-
+
In CoffeeScript, an object literal is simply a list of assignments.
@@ -794,11 +830,11 @@ or by array index or slice.
-
+
Assignment of properties within an object literal can be separated by
comma, as in JavaScript, or simply by newline.
@@ -816,11 +852,11 @@ comma, as in JavaScript, or simply by newline.
-
+
Class definitions have optional bodies of prototype property assignments,
and optional references to the superclass.
@@ -841,11 +877,11 @@ and optional references to the superclass.
-
+
Ordinary function invocation, or a chained series of calls.
@@ -861,11 +897,11 @@ and optional references to the superclass.
-
+
An optional existence check on a function.
@@ -879,11 +915,11 @@ and optional references to the superclass.
-
+
The list of arguments to a function call.
@@ -897,11 +933,11 @@ and optional references to the superclass.
-
+
A reference to the this current object.
@@ -915,11 +951,11 @@ and optional references to the superclass.
-
+
A reference to a property on this.
@@ -932,11 +968,11 @@ and optional references to the superclass.
-
+
The array literal.
@@ -950,11 +986,11 @@ and optional references to the superclass.
-
+
Inclusive and exclusive range dots.
@@ -968,11 +1004,11 @@ and optional references to the superclass.
-
+
The CoffeeScript range literal.
@@ -985,11 +1021,11 @@ and optional references to the superclass.
-
+
Array slice literals.
@@ -1005,11 +1041,11 @@ and optional references to the superclass.
-
+
The ArgList is both the list of objects passed into a function call,
as well as the contents of an array literal
@@ -1028,11 +1064,11 @@ as well as the contents of an array literal
-
+
Valid arguments are Blocks or Splats.
@@ -1047,15 +1083,15 @@ as well as the contents of an array literal
-
+
@@ -1067,11 +1103,11 @@ having the newlines wouldn't make sense.
-
+
The variants of try/catch/finally exception handling blocks.
@@ -1087,11 +1123,11 @@ having the newlines wouldn't make sense.
-
+
A catch clause names its error and runs a block of code.
@@ -1106,11 +1142,11 @@ having the newlines wouldn't make sense.
-
+
Throw an exception object.
@@ -1123,11 +1159,11 @@ having the newlines wouldn't make sense.
-
+
Parenthetical expressions. Note that the Parenthetical is a Value,
not an Expression, so if you need to use an expression in a place
@@ -1144,11 +1180,11 @@ the trick.
-
+
The condition portion of a while loop.
@@ -1164,11 +1200,11 @@ the trick.
-
+
The while loop can either be normal, with a block of expressions to execute,
or postfix, with a single expression. There is no do..while.
@@ -1190,11 +1226,11 @@ or postfix, with a single expression. There is no do..while.
-
+
Array, object, and range comprehensions, at the most generic level.
Comprehensions can either be normal, with a block of expressions to execute,
@@ -1221,11 +1257,11 @@ or postfix, with a single expression.
-
+
An array of all accepted values for a variable inside the loop.
This enables support for pattern matching.
@@ -1242,11 +1278,11 @@ This enables support for pattern matching.
-
+
An array or range comprehension has variables for the current element
and (optional) reference to the current index. Or, key, value, in the case
@@ -1262,14 +1298,14 @@ of object comprehensions.
-
+
@@ -1299,11 +1335,11 @@ in fixed-size increments.
-
+
An individual When clause, with action.
@@ -1317,11 +1353,11 @@ in fixed-size increments.
-
+
The most basic form of if is a condition and an action. The following
if-related rules are broken up along these lines in order to avoid
@@ -1337,11 +1373,11 @@ ambiguity.
-
+
The full complement of if expressions, including postfix one-liner
if and unless.
@@ -1358,11 +1394,11 @@ ambiguity.
-
+
Arithmetic and logical operators, working on one or more operands.
Here they are grouped by order of precedence. The actual precedence rules
@@ -1387,11 +1423,11 @@ rules are necessary.
-
+
@@ -1425,11 +1461,11 @@ rules are necessary.
-
+
Precedence
@@ -1438,17 +1474,29 @@ rules are necessary.
-
+
+
+
+
+
+
+
+
+
+ ¶
Operators at the top of this list have higher precedence than the ones lower
down. Following these rules is what makes 2 + 3 * 4
parse as:
-2 + (3 * 4)
+2 + (3 * 4)
And not:
-(2 + 3) * 4
+(2 + 3) * 4
@@ -1476,11 +1524,11 @@ down. Following these rules is what makes 2 + 3 * 4
parse as:
-
+
Wrapping Up
@@ -1489,16 +1537,28 @@ down. Following these rules is what makes 2 + 3 * 4
parse as:
-
+
+
+
+
+
+
+
+
+
+ ¶
Finally, now that we have our grammar and our operators, we can create
our Jison.Parser. We do this by processing all of our rules, recording all
terminals (every symbol which does not appear as the name of a rule above)
-as "tokens".
+as “tokens”.
@@ -1513,11 +1573,11 @@ as "tokens".
-
+
Initialize the Parser with our list of terminal tokens, our grammar
rules, and the name of the root. Reverse the operators because Jison orders
diff --git a/documentation/docs/helpers.html b/documentation/docs/helpers.html
index bdfa4767..35807f29 100644
--- a/documentation/docs/helpers.html
+++ b/documentation/docs/helpers.html
@@ -113,16 +113,12 @@
- This file contains the common helper functions that we'd like to share among
+
This file contains the common helper functions that we’d like to share among
the Lexer, Rewriter, and the Nodes. Merge objects, flatten
arrays, count characters, that sort of thing.
-Peek at the beginning of a given string to see if it matches a sequence.
- exports.starts = (string, literal, start) ->
- literal is string.substr start, literal.length
-
@@ -132,6 +128,22 @@ arrays, count characters, that sort of thing.
+ Peek at the beginning of a given string to see if it matches a sequence.
+
+
+
+ exports.starts = (string, literal, start) ->
+ literal is string.substr start, literal.length
+
+
+
+
+
+
+
+
+ ¶
+
Peek at the end of a given string to see if it matches a sequence.
@@ -143,11 +155,11 @@ arrays, count characters, that sort of thing.
-
+
Repeat a string n
times.
@@ -158,11 +170,11 @@ arrays, count characters, that sort of thing.
-
+
Use clever algorithm to have O(log(n)) string concatenation operations.
@@ -178,11 +190,11 @@ arrays, count characters, that sort of thing.
-
+
Trim out all falsy values from an array.
@@ -194,11 +206,11 @@ arrays, count characters, that sort of thing.
-
+
Count the number of occurrences of a string in a string.
@@ -213,11 +225,11 @@ arrays, count characters, that sort of thing.
-
+
Merge objects, returning a fresh copy with attributes from both sides.
Used every time Base#compile
is called, to allow properties in the
@@ -231,11 +243,11 @@ options hash to propagate down the tree without polluting other branches.
-
+
Extend a source object with the properties of another object (shallow copy).
@@ -249,11 +261,11 @@ options hash to propagate down the tree without polluting other branches.
-
+
Return a flattened version of an array.
Handy for getting a list of children
from the nodes.
@@ -272,11 +284,11 @@ Handy for getting a list of children
from the nodes.
-
+
Delete a key from an object, returning the value. Useful when a node is
looking for a particular method in an options hash.
@@ -291,11 +303,11 @@ looking for a particular method in an options hash.
-
+
Gets the last item of an array(-like) object.
@@ -306,11 +318,11 @@ looking for a particular method in an options hash.
-
+
Typical Array::some
@@ -323,15 +335,15 @@ looking for a particular method in an options hash.
-
+
@@ -349,11 +361,11 @@ can be compiled "normally".
-
+
Merge two jison-style location data objects together.
If last
is not provided, this will simply return first
.
@@ -372,14 +384,14 @@ If last
is not provided, this will simply return first
-
+
@@ -394,11 +406,11 @@ The object is returned either way.
-
+
Convert jison location data to a string.
obj
can be a token, or a locationData.
@@ -418,11 +430,11 @@ The object is returned either way.
-
+
A .coffee.md
compatible version of basename
, that returns the file sans-extension.
@@ -441,11 +453,11 @@ The object is returned either way.
-
+
Determine if a filename represents a CoffeeScript file.
@@ -456,11 +468,11 @@ The object is returned either way.
-
+
Determine if a filename represents a Literate CoffeeScript file.
@@ -471,14 +483,14 @@ The object is returned either way.
-
+
Throws a SyntaxError from a given location.
-The error's toString
will return an error message following the "standard"
+The error’s toString
will return an error message following the “standard”
format :: : plus the line with the error and a
marker showing where the error is.
@@ -492,13 +504,13 @@ marker showing where the error is.
-
+
- Instead of showing the compiler's stacktrace, show our custom error message
+
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).
@@ -511,13 +523,13 @@ compile CoffeeScript for example).
-
+
@@ -527,11 +539,11 @@ it already.
-
+
Avoid screwing up the stack
property of other errors (i.e. possible bugs).
@@ -557,29 +569,29 @@ it already.
-
-
-
-
- ¶
-
- Show only the first line on multi-line errors.
-
-
-
- end = if first_line is last_line then last_column + 1 else codeLine.length
- marker = repeat(' ', start) + repeat('^', end - start)
-
-
-
-
- Check to see if we're running on a color-enabled TTY.
+ Show only the first line on multi-line errors.
+
+
+
+ end = if first_line is last_line then last_column + 1 else codeLine.length
+ marker = codeLine[...start].replace(/[^\s]/g, ' ') + repeat('^', end - start)
+
+
+
+
+
+
+
+
+ ¶
+
+ Check to see if we’re running on a color-enabled TTY.
diff --git a/documentation/docs/lexer.html b/documentation/docs/lexer.html
index 3a375b8d..46abbbaf 100644
--- a/documentation/docs/lexer.html
+++ b/documentation/docs/lexer.html
@@ -124,7 +124,8 @@ are read by jison in the parser.lexer
function defined in coffee-sc
- {Rewriter, INVERSES} = require './rewriter'
+
+{Rewriter, INVERSES} = require './rewriter'
@@ -164,6 +165,18 @@ locationDataToString, throwSyntaxError} = require
+
+
+
+
+
+
+
+
+
+
+ ¶
+
The Lexer class reads a stream of CoffeeScript and divvies it up into tagged
tokens. Some potential ambiguity in the grammar has been avoided by
pushing some extra smarts into the Lexer.
@@ -175,13 +188,13 @@ pushing some extra smarts into the Lexer.
-
+
- tokenize is the Lexer's main method. Scan by attempting to match tokens
+
tokenize is the Lexer’s main method. Scan by attempting to match tokens
one at a time, using a regular expression anchored at the start of the
remaining code, or a custom recursive token-matching method
(for interpolations). When the next token has been recorded, we move forward
@@ -212,11 +225,11 @@ unless explicitly asked not to.
-
+
At every position, run through this list of attempted matches,
short-circuiting if any of them succeed. Their order determines precedence:
@@ -241,11 +254,11 @@ short-circuiting if any of them succeed. Their order determines precedence:
-
+
Update position
@@ -263,15 +276,15 @@ short-circuiting if any of them succeed. Their order determines precedence:
-
+
Preprocess the code to remove leading and trailing whitespace, carriage
-returns, etc. If we're lexing literate CoffeeScript, strip external Markdown
-by removing all lines that aren't indented by at least four spaces or a tab.
+returns, etc. If we’re lexing literate CoffeeScript, strip external Markdown
+by removing all lines that aren’t indented by at least four spaces or a tab.
@@ -287,11 +300,11 @@ by removing all lines that aren't indented by at least four spaces or a tab.
-
+
Tokenizers
@@ -300,16 +313,28 @@ by removing all lines that aren't indented by at least four spaces or a tab.
-
+
+
+
+
+
+
+
+
+
+ ¶
Matches identifying literals: variables, keywords, method names, etc.
-Check to ensure that JavaScript reserved words aren't being used as
+Check to ensure that JavaScript reserved words aren’t being used as
identifiers. Because CoffeeScript reserves a handful of keywords that are
-allowed in JavaScript, we're careful not to tag them as keywords when
+allowed in JavaScript, we’re careful not to tag them as keywords when
referenced as property names here, so you can still do jQuery.is()
even
though is
means ===
otherwise.
@@ -322,11 +347,11 @@ though is
means ===
otherwise.
-
+
Preserve length of id for location data
@@ -394,11 +419,11 @@ though is
means ===
otherwise.
-
+
Matches numbers, including decimals, hex, and exponential notation.
Be careful not to interfere with ranges-in-progress.
@@ -427,25 +452,29 @@ Be careful not to interfere with ranges-in-progress.
-
+
Matches strings, including multi-line strings. Ensures that quotation marks
-are balanced within the string's contents, and within nested interpolations.
+are balanced within the string’s contents, and within nested interpolations.
stringToken: ->
switch quote = @chunk.charAt 0
- when "'" then [string] = SIMPLESTR.exec @chunk
+ when "'" then [string] = SIMPLESTR.exec(@chunk) || []
when '"' then string = @balancedString @chunk, '"'
return 0 unless string
- trimmed = @removeNewlines string[1...-1]
+ inner = string[1...-1]
+ trimmed = @removeNewlines inner
if quote is '"' and 0 < string.indexOf '#{', 1
- @interpolateString trimmed, strOffset: 1, lexedLength: string.length
+ numBreak = pos = 0
+ innerLen = inner.length
+ numBreak++ while inner.charAt(pos++) is '\n' and pos < innerLen
+ @interpolateString trimmed, strOffset: 1 + numBreak, lexedLength: string.length
else
@token 'STRING', quote + @escapeLines(trimmed) + quote, 0, string.length
if octalEsc = /^(?:\\.|[^\\])*\\(?:0[0-7]|[1-7])/.test string
@@ -455,11 +484,11 @@ are balanced within the string's contents, and within nested interpolations.
-
+
Matches heredocs, adjusting indentation to the correct level, as heredocs
preserve whitespace, but ignore indentation to the left.
@@ -472,7 +501,8 @@ preserve whitespace, but ignore indentation to the left.
quote = heredoc.charAt 0
doc = @sanitizeHeredoc match[2], quote: quote, indent: null
if quote is '"' and 0 <= doc.indexOf '#{'
- @interpolateString doc, heredoc: yes, strOffset: 3, lexedLength: heredoc.length
+ strOffset = if match[2].charAt(0) is '\n' then 4 else 3
+ @interpolateString doc, heredoc: yes, strOffset: strOffset, lexedLength: heredoc.length
else
@token 'STRING', @makeString(doc, quote, yes), 0, heredoc.length
heredoc.length
@@ -480,11 +510,11 @@ preserve whitespace, but ignore indentation to the left.
-
+
Matches and consumes comments.
@@ -503,11 +533,11 @@ preserve whitespace, but ignore indentation to the left.
-
+
Matches JavaScript interpolated directly into the source via backticks.
@@ -521,11 +551,11 @@ preserve whitespace, but ignore indentation to the left.
-
+
Matches regular expression literals. Lexing regular expressions is difficult
to distinguish from division, so we borrow some basic heuristics from
@@ -545,11 +575,11 @@ JavaScript and Ruby.
-
+
Avoid conflicts with floor division operator.
@@ -563,11 +593,11 @@ JavaScript and Ruby.
-
+
Matches multiline extended regular expressions.
@@ -584,7 +614,7 @@ JavaScript and Ruby.
@token 'IDENTIFIER', 'RegExp', 0, 0
@token 'CALL_START', '(', 0, 0
tokens = []
- for token in @interpolateString(body, regex: yes)
+ for token in @interpolateString(body, regex: yes, strOffset: 3)
[tag, value] = token
if tag is 'TOKENS'
tokens.push value...
@@ -595,11 +625,11 @@ JavaScript and Ruby.
-
+
Convert NEOSTRING into STRING
@@ -620,13 +650,13 @@ JavaScript and Ruby.
-
+
@@ -642,11 +672,11 @@ JavaScript and Ruby.
-
+
Find the flags in the heregex
@@ -662,11 +692,11 @@ JavaScript and Ruby.
-
+
Matches newlines, indents, and outdents, and determines which is which.
If we can detect that the current line is continued onto the the next line,
@@ -713,11 +743,11 @@ can close multiple indents, so we need to know how far in we happen to be.
-
+
Record an outdent token or multiple tokens, if we happen to be moving back
inwards past several recorded indents. Sets new @indent value.
@@ -746,11 +776,11 @@ inwards past several recorded indents. Sets new @indent value.
-
+
pair might call outdentToken, so preserve decreasedIndent
@@ -769,14 +799,14 @@ inwards past several recorded indents. Sets new @indent value.
-
+
@@ -790,11 +820,11 @@ as being "spaced", because there are some cases where it makes a diffe
-
+
Generate a newline token. Consecutive newlines get merged together.
@@ -808,11 +838,11 @@ as being "spaced", because there are some cases where it makes a diffe
-
+
Use a \
at a line-ending to suppress the newline.
The slash is removed here once its job is done.
@@ -826,11 +856,11 @@ The slash is removed here once its job is done.
-
+
We treat all other single characters as a token. E.g.: ( ) , . !
Multi-character operators are also literal tokens, so that Jison can assign
@@ -882,11 +912,11 @@ parentheses that indicate a method call from regular parentheses, and so on.
-
+
Token Manipulators
@@ -895,11 +925,23 @@ parentheses that indicate a method call from regular parentheses, and so on.
-
+
+
+
+
+
+
+
+
+
+ ¶
Sanitize a heredoc or herecomment by
erasing all external indentation on the left-hand side.
@@ -923,11 +965,11 @@ erasing all external indentation on the left-hand side.
-
+
A source of ambiguity in our grammar used to be parameter lists in function
definitions versus argument lists in function calls. Walk backwards, tagging
@@ -956,11 +998,11 @@ parameters specially in order to make things easier for the parser.
-
+
Close up all remaining open blocks at the end of the file.
@@ -972,11 +1014,11 @@ parameters specially in order to make things easier for the parser.
-
+