<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to coffeescriptProcedure</title><link>https://sourceforge.net/p/qwpr/wiki/coffeescriptProcedure/</link><description>Recent changes to coffeescriptProcedure</description><atom:link href="https://sourceforge.net/p/qwpr/wiki/coffeescriptProcedure/feed" rel="self"/><language>en</language><lastBuildDate>Fri, 15 Mar 2013 00:42:00 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/qwpr/wiki/coffeescriptProcedure/feed" rel="self" type="application/rss+xml"/><item><title>WikiPage coffeescriptProcedure modified by Jameson Quinn</title><link>https://sourceforge.net/p/qwpr/wiki/coffeescriptProcedure/</link><description>&lt;div class="markdown_content"&gt;&lt;ol&gt;
&lt;li&gt;Took coffeescript.coffee&lt;/li&gt;
&lt;li&gt;Globally changed /^  / to "\t"&lt;/li&gt;
&lt;li&gt;Repeatedly changed /^(\t+)(&lt;span&gt;[^\t\n]&lt;/span&gt;*?)(\n\1&lt;span&gt;[^\t]&lt;/span&gt;)/ to "\2\3" (so that only changes in tab level end up as tabs; assuming your editor adds them automatically if there's no change from prior line. Thus reductions in tab level end up as a tab too... that's one fewer "shift" but all the layouts will suffer equally on this point.)&lt;/li&gt;
&lt;li&gt;Repeatedly lobally changed /\t+/ to "\t" (reduce all tabs to one)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Result is the following, so you don't have to do it yourself:&lt;/p&gt;
&lt;h1 id="coffeescript-can-be-used-both-on-the-server-as-a-command-line-compiler-based"&gt;CoffeeScript can be used both on the server, as a command-line compiler based&lt;/h1&gt;
&lt;h1 id="on-nodejsv8-or-to-run-coffeescripts-directly-in-the-browser-this-module"&gt;on Node.js/V8, or to run CoffeeScripts directly in the browser. This module&lt;/h1&gt;
&lt;h1 id="contains-the-main-entry-functions-for-tokenizing-parsing-and-compiling"&gt;contains the main entry functions for tokenizing, parsing, and compiling&lt;/h1&gt;
&lt;h1 id="source-coffeescript-into-javascript"&gt;source CoffeeScript into JavaScript.&lt;/h1&gt;
&lt;h1&gt;&lt;/h1&gt;
&lt;h1 id="if-included-on-a-webpage-it-will-automatically-sniff-out-compile-and"&gt;If included on a webpage, it will automatically sniff out, compile, and&lt;/h1&gt;
&lt;h1 id="execute-all-scripts-present-in-textcoffeescript-tags"&gt;execute all scripts present in &lt;code&gt;text/coffeescript&lt;/code&gt; tags.&lt;/h1&gt;
&lt;p&gt;fs        = require 'fs'&lt;br /&gt;
path      = require 'path'&lt;br /&gt;
{Lexer}   = require './lexer'&lt;br /&gt;
{parser}  = require './parser'&lt;br /&gt;
helpers   = require './helpers'&lt;br /&gt;
vm        = require 'vm'&lt;br /&gt;
sourcemap = require './sourcemap'&lt;/p&gt;
&lt;h1 id="load-and-run-a-coffeescript-file-for-node-stripping-any-boms"&gt;Load and run a CoffeeScript file for Node, stripping any &lt;code&gt;BOM&lt;/code&gt;s.&lt;/h1&gt;
&lt;p&gt;loadFile = (module, filename) -&amp;gt;&lt;br /&gt;
raw = fs.readFileSync filename, 'utf8'&lt;br /&gt;
stripped = if raw.charCodeAt(0) is 0xFEFF then raw.substring 1 else raw&lt;br /&gt;
    module._compile compile(stripped, {filename, literate: helpers.isLiterate filename}), filename&lt;/p&gt;
&lt;p&gt;if require.extensions&lt;br /&gt;
    for ext in &lt;span&gt;['.coffee', '.litcoffee', '.md', '.coffee.md']&lt;/span&gt;&lt;br /&gt;
    require.extensions&lt;span&gt;[ext]&lt;/span&gt; = loadFile&lt;/p&gt;
&lt;h1 id="the-current-coffeescript-version-number"&gt;The current CoffeeScript version number.&lt;/h1&gt;
&lt;p&gt;exports.VERSION = '1.6.1'&lt;/p&gt;
&lt;h1 id="expose-helpers-for-testing"&gt;Expose helpers for testing.&lt;/h1&gt;
&lt;p&gt;exports.helpers = helpers&lt;/p&gt;
&lt;h1 id="compile-coffeescript-code-to-javascript-using-the-coffeejison-compiler"&gt;Compile CoffeeScript code to JavaScript, using the Coffee/Jison compiler.&lt;/h1&gt;
&lt;h1&gt;&lt;/h1&gt;
&lt;h1 id="if-optionssourcemap-is-specified-then-optionsfilename-must-also-be-specified-all"&gt;If &lt;code&gt;options.sourceMap&lt;/code&gt; is specified, then &lt;code&gt;options.filename&lt;/code&gt; must also be specified.  All&lt;/h1&gt;
&lt;h1 id="options-that-can-be-passed-to-generatev3sourcemap-may-also-be-passed-here"&gt;options that can be passed to &lt;code&gt;generateV3SourceMap()&lt;/code&gt; may also be passed here.&lt;/h1&gt;
&lt;h1&gt;&lt;/h1&gt;
&lt;h1 id="this-returns-a-javascript-string-unless-optionssourcemap-is-passed"&gt;This returns a javascript string, unless &lt;code&gt;options.sourceMap&lt;/code&gt; is passed,&lt;/h1&gt;
&lt;h1 id="in-which-case-this-returns-a-js-v3sourcemap-sourcemap"&gt;in which case this returns a `{js, v3SourceMap, sourceMap}&lt;/h1&gt;
&lt;h1 id="object-where-sourcemap-is-a-sourcemapcoffeesourcemap-object-handy-for-doing-programatic"&gt;object, where sourceMap is a sourcemap.coffee#SourceMap object, handy for doing programatic&lt;/h1&gt;
&lt;h1 id="lookups"&gt;lookups.&lt;/h1&gt;
&lt;p&gt;exports.compile = compile = (code, options = {}) -&amp;gt;&lt;br /&gt;
    {merge} = exports.helpers&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sourceMap&lt;/span&gt;
&lt;span class="n"&gt;sourceMap&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;sourcemap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SourceMap&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;fragments&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parse&lt;/span&gt; &lt;span class="n"&gt;lexer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tokenize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="n"&gt;compileToFragments&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;currentLine = 0&lt;br /&gt;
currentLine += 1 if options.header&lt;br /&gt;
currentColumn = 0&lt;br /&gt;
js = ""&lt;br /&gt;
    for fragment in fragments&lt;/p&gt;
&lt;h1 id="update-the-sourcemap-with-data-from-each-fragment"&gt;Update the sourcemap with data from each fragment&lt;/h1&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;sourceMap&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;fragment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;locationData&lt;/span&gt;
&lt;span class="n"&gt;sourceMap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;addMapping&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;span&gt;[fragment.locationData.first_line, fragment.locationData.first_column]&lt;/span&gt;,&lt;br /&gt;
&lt;span&gt;[currentLine, currentColumn]&lt;/span&gt;,&lt;br /&gt;
    {noReplace: true})&lt;br /&gt;
newLines = helpers.count fragment.code, "\n"&lt;br /&gt;
currentLine += newLines&lt;br /&gt;
    currentColumn = fragment.code.length - (if newLines then fragment.code.lastIndexOf "\n" else 0)&lt;/p&gt;
&lt;h1 id="copy-the-code-from-each-fragment-into-the-final-javascript"&gt;Copy the code from each fragment into the final JavaScript.&lt;/h1&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="n"&gt;js&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fragment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;header&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;header = "Generated by CoffeeScript #{@VERSION}"&lt;br /&gt;
    js = "// #{header}\n#{js}"&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sourceMap&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;answer = {js}&lt;br /&gt;
    if sourceMap&lt;br /&gt;
answer.sourceMap = sourceMap&lt;br /&gt;
    answer.v3SourceMap = sourcemap.generateV3SourceMap(sourceMap, options)&lt;br /&gt;
    answer&lt;br /&gt;
    else&lt;br /&gt;
    js&lt;/p&gt;
&lt;h1 id="tokenize-a-string-of-coffeescript-code-and-return-the-array-of-tokens"&gt;Tokenize a string of CoffeeScript code, and return the array of tokens.&lt;/h1&gt;
&lt;p&gt;exports.tokens = (code, options) -&amp;gt;&lt;br /&gt;
    lexer.tokenize code, options&lt;/p&gt;
&lt;h1 id="parse-a-string-of-coffeescript-code-or-an-array-of-lexed-tokens-and"&gt;Parse a string of CoffeeScript code or an array of lexed tokens, and&lt;/h1&gt;
&lt;h1 id="return-the-ast-you-can-then-compile-it-by-calling-compile-on-the-root"&gt;return the AST. You can then compile it by calling &lt;code&gt;.compile()&lt;/code&gt; on the root,&lt;/h1&gt;
&lt;h1 id="or-traverse-it-by-using-traversechildren-with-a-callback"&gt;or traverse it by using &lt;code&gt;.traverseChildren()&lt;/code&gt; with a callback.&lt;/h1&gt;
&lt;p&gt;exports.nodes = (source, options) -&amp;gt;&lt;br /&gt;
    if typeof source is 'string'&lt;br /&gt;
    parser.parse lexer.tokenize source, options&lt;br /&gt;
    else&lt;br /&gt;
    parser.parse source&lt;/p&gt;
&lt;h1 id="compile-and-execute-a-string-of-coffeescript-on-the-server-correctly"&gt;Compile and execute a string of CoffeeScript (on the server), correctly&lt;/h1&gt;
&lt;h1 id="setting-__filename-__dirname-and-relative-require"&gt;setting &lt;code&gt;__filename&lt;/code&gt;, &lt;code&gt;__dirname&lt;/code&gt;, and relative &lt;code&gt;require()&lt;/code&gt;.&lt;/h1&gt;
&lt;p&gt;exports.run = (code, options = {}) -&amp;gt;&lt;br /&gt;
mainModule = require.main&lt;br /&gt;
options.sourceMap ?= true&lt;/p&gt;
&lt;h1 id="set-the-filename"&gt;Set the filename.&lt;/h1&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="n"&gt;mainModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;1&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt; &lt;span class="n"&gt;then&lt;/span&gt; &lt;span class="n"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;realpathSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s"&gt;'.'&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h1 id="clear-the-module-cache"&gt;Clear the module cache.&lt;/h1&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="n"&gt;mainModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;moduleCache&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h1 id="assign-paths-for-node_modules-loading"&gt;Assign paths for node_modules loading&lt;/h1&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="n"&gt;mainModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;paths&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'module'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;_nodeModulePaths&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dirname&lt;/span&gt; &lt;span class="n"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;realpathSync&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt; &lt;span class="n"&gt;or&lt;/span&gt; &lt;span class="s"&gt;'.'&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h1 id="compile"&gt;Compile.&lt;/h1&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;not&lt;/span&gt; &lt;span class="n"&gt;helpers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isCoffee&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mainModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;or&lt;/span&gt; &lt;span class="n"&gt;require&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extensions&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;answer = compile(code, options)&lt;/p&gt;
&lt;h1 id="attach-sourcemap-object-to-mainmodule_sourcemapsoptionsfilename-so-that"&gt;Attach sourceMap object to mainModule._sourceMaps&lt;span&gt;[options.filename]&lt;/span&gt; so that&lt;/h1&gt;
&lt;h1 id="it-is-accessible-by-errorpreparestacktrace"&gt;it is accessible by Error.prepareStackTrace.&lt;/h1&gt;
&lt;p&gt;do patchStackTrace&lt;br /&gt;
mainModule._sourceMaps&lt;span&gt;[mainModule.filename]&lt;/span&gt; = answer.sourceMap&lt;br /&gt;
    mainModule._compile answer.js, mainModule.filename&lt;br /&gt;
    else&lt;br /&gt;
    mainModule._compile code, mainModule.filename&lt;/p&gt;
&lt;h1 id="compile-and-evaluate-a-string-of-coffeescript-in-a-nodejs-like-environment"&gt;Compile and evaluate a string of CoffeeScript (in a Node.js-like environment).&lt;/h1&gt;
&lt;h1 id="the-coffeescript-repl-uses-this-to-run-the-input"&gt;The CoffeeScript REPL uses this to run the input.&lt;/h1&gt;
&lt;p&gt;exports.eval = (code, options = {}) -&amp;gt;&lt;br /&gt;
return unless code = code.trim()&lt;br /&gt;
Script = vm.Script&lt;br /&gt;
    if Script&lt;br /&gt;
    if options.sandbox?&lt;br /&gt;
    if options.sandbox instanceof Script.createContext().constructor&lt;br /&gt;
    sandbox = options.sandbox&lt;br /&gt;
    else&lt;br /&gt;
sandbox = Script.createContext()&lt;br /&gt;
    sandbox&lt;span&gt;[k]&lt;/span&gt; = v for own k, v of options.sandbox&lt;br /&gt;
    sandbox.global = sandbox.root = sandbox.GLOBAL = sandbox&lt;br /&gt;
    else&lt;br /&gt;
    sandbox = global&lt;br /&gt;
sandbox.&lt;strong&gt;filename = options.filename || 'eval'&lt;br /&gt;
sandbox.&lt;/strong&gt;dirname  = path.dirname sandbox.__filename&lt;/p&gt;
&lt;h1 id="define-modulerequire-only-if-they-chose-not-to-specify-their-own"&gt;define module/require only if they chose not to specify their own&lt;/h1&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="n"&gt;unless&lt;/span&gt; &lt;span class="n"&gt;sandbox&lt;/span&gt; &lt;span class="n"&gt;isnt&lt;/span&gt; &lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="n"&gt;or&lt;/span&gt; &lt;span class="n"&gt;sandbox&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;module&lt;/span&gt; &lt;span class="n"&gt;or&lt;/span&gt; &lt;span class="n"&gt;sandbox&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;require&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Module = require 'module'&lt;br /&gt;
sandbox.module  = _module  = new Module(options.modulename || 'eval')&lt;br /&gt;
sandbox.require = _require = (path) -&amp;gt;  Module._load path, _module, true&lt;br /&gt;
_module.filename = sandbox.__filename&lt;br /&gt;
_require&lt;span&gt;[r]&lt;/span&gt; = require&lt;span&gt;[r]&lt;/span&gt; for r in Object.getOwnPropertyNames require when r isnt 'paths'&lt;/p&gt;
&lt;h1 id="use-the-same-hack-node-currently-uses-for-their-own-repl"&gt;use the same hack node currently uses for their own REPL&lt;/h1&gt;
&lt;p&gt;_require.paths = _module.paths = Module._nodeModulePaths process.cwd()&lt;br /&gt;
    _require.resolve = (request) -&amp;gt; Module._resolveFilename request, _module&lt;br /&gt;
o = {}&lt;br /&gt;
o&lt;span&gt;[k]&lt;/span&gt; = v for own k, v of options&lt;br /&gt;
o.bare = on # ensure return value&lt;br /&gt;
js = compile code, o&lt;br /&gt;
    if sandbox is global&lt;br /&gt;
    vm.runInThisContext js&lt;br /&gt;
    else&lt;br /&gt;
    vm.runInContext js, sandbox&lt;/p&gt;
&lt;h1 id="instantiate-a-lexer-for-our-use-here"&gt;Instantiate a Lexer for our use here.&lt;/h1&gt;
&lt;p&gt;lexer = new Lexer&lt;/p&gt;
&lt;h1 id="the-real-lexer-produces-a-generic-stream-of-tokens-this-object-provides-a"&gt;The real Lexer produces a generic stream of tokens. This object provides a&lt;/h1&gt;
&lt;h1 id="thin-wrapper-around-it-compatible-with-the-jison-api-we-can-then-pass-it"&gt;thin wrapper around it, compatible with the Jison API. We can then pass it&lt;/h1&gt;
&lt;h1 id="directly-as-a-jison-lexer"&gt;directly as a "Jison lexer".&lt;/h1&gt;
&lt;p&gt;parser.lexer =&lt;br /&gt;
    lex: -&amp;gt;&lt;br /&gt;
token = @tokens&lt;span&gt;[@pos++]&lt;/span&gt;&lt;br /&gt;
    if token&lt;br /&gt;
&lt;span&gt;[tag, @yytext, @yylloc]&lt;/span&gt; = token&lt;br /&gt;
    @yylineno = @yylloc.first_line&lt;br /&gt;
    else&lt;br /&gt;
    tag = ''&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="n"&gt;tag&lt;/span&gt;
&lt;span class="n"&gt;setInput&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(@&lt;/span&gt;&lt;span class="n"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="n"&gt;pos&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; 0
&lt;span class="n"&gt;upcomingInput&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
&amp;quot;&amp;quot;
&lt;/pre&gt;&lt;/div&gt;


&lt;h1 id="make-all-the-ast-nodes-visible-to-the-parser"&gt;Make all the AST nodes visible to the parser.&lt;/h1&gt;
&lt;p&gt;parser.yy = require './nodes'&lt;/p&gt;
&lt;h1 id="override-jisons-default-error-handling-function"&gt;Override Jison's default error handling function.&lt;/h1&gt;
&lt;p&gt;parser.yy.parseError = (message, {token}) -&amp;gt;&lt;/p&gt;
&lt;h1 id="disregard-jisons-message-it-contains-redundant-line-numer-information"&gt;Disregard Jison's message, it contains redundant line numer information.&lt;/h1&gt;
&lt;p&gt;message = "unexpected #{if token is 1 then 'end of input' else token}"&lt;/p&gt;
&lt;h1 id="the-second-argument-has-a-loc-property-which-should-have-the-location"&gt;The second argument has a &lt;code&gt;loc&lt;/code&gt; property, which should have the location&lt;/h1&gt;
&lt;h1 id="data-for-this-token-unfortunately-jison-seems-to-send-an-outdated-loc"&gt;data for this token. Unfortunately, Jison seems to send an outdated &lt;code&gt;loc&lt;/code&gt;&lt;/h1&gt;
&lt;h1 id="from-the-previous-token-so-we-take-the-location-information-directly"&gt;(from the previous token), so we take the location information directly&lt;/h1&gt;
&lt;h1 id="from-the-lexer"&gt;from the lexer.&lt;/h1&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="n"&gt;helpers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;throwSyntaxError&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lexer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;yylloc&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h1 id="based-on-michaelficarracoffeescriptredux"&gt;Based on &lt;a class="" href="http://goo.gl/ZTx1p"&gt;michaelficarra/CoffeeScriptRedux&lt;/a&gt;&lt;/h1&gt;
&lt;h1 id="nodejs-v8-have-no-support-for-transforming-positions-in-stack-traces-using"&gt;NodeJS / V8 have no support for transforming positions in stack traces using&lt;/h1&gt;
&lt;h1 id="sourcemap-so-we-must-monkey-patch-error-to-display-coffeescript-source"&gt;sourceMap, so we must monkey-patch Error to display CoffeeScript source&lt;/h1&gt;
&lt;h1 id="positions"&gt;positions.&lt;/h1&gt;
&lt;h1 id="ideally-this-would-happen-in-a-way-that-is-scalable-to-multiple-compile-to-"&gt;Ideally, this would happen in a way that is scalable to multiple compile-to-&lt;/h1&gt;
&lt;h1 id="js-languages-trying-to-do-the-same-thing-in-the-same-nodejs-process-we-can"&gt;JS languages trying to do the same thing in the same NodeJS process. We can&lt;/h1&gt;
&lt;h1 id="implement-it-as-if-there-were-an-api-and-then-patch-in-support-for-that"&gt;implement it as if there were an API, and then patch in support for that&lt;/h1&gt;
&lt;h1 id="api-the-following-maybe-should-be-in-its-own-npm-module-that-multiple"&gt;API. The following maybe should be in its own npm module that multiple&lt;/h1&gt;
&lt;h1 id="compilers-can-include"&gt;compilers can include.&lt;/h1&gt;
&lt;p&gt;patched = false&lt;br /&gt;
patchStackTrace = -&amp;gt;&lt;br /&gt;
return if patched&lt;br /&gt;
patched = true&lt;br /&gt;
mainModule = require.main&lt;/p&gt;
&lt;h1 id="map-of-filenames-functions-that-return-a-sourcemap-string"&gt;Map of filenames -&amp;gt; functions that return a sourceMap string.&lt;/h1&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="n"&gt;mainModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_sourceMaps&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h1 id="assigning-to-a-property-of-the-module-object-in-the-normal-module-cache-is"&gt;(Assigning to a property of the Module object in the normal module cache is&lt;/h1&gt;
&lt;h1 id="unsuitable-because-node-deletes-those-objects-from-the-cache-if-an"&gt;unsuitable, because node deletes those objects from the cache if an&lt;/h1&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="c"&gt;# exception is thrown in the module body.)&lt;/span&gt;

&lt;span class="n"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;prepareStackTrace&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
&lt;span class="n"&gt;sourceFiles&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

&lt;span class="n"&gt;getSourceMapping&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;line&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;sourceMap = mainModule._sourceMaps&lt;span&gt;[filename]&lt;/span&gt;&lt;br /&gt;
answer = sourceMap.getSourcePosition &lt;span&gt;[line, column]&lt;/span&gt; if sourceMap&lt;br /&gt;
    answer&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="n"&gt;frames&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;break if frame.getFunction() is exports.run&lt;br /&gt;
    "  at #{formatSourcePosition frame, getSourceMapping}"&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&amp;quot;#&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}:&lt;/span&gt; #&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt; ? &lt;span class="s"&gt;''&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;\&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;#&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;frames&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt; &lt;span class="s"&gt;'\n'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;\&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&amp;quot;
&lt;/pre&gt;&lt;/div&gt;


&lt;h1 id="based-on-httpv8googlecodecomsvnbranchesbleeding_edgesrcmessagesjs"&gt;Based on &lt;a href="http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js"&gt;http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js&lt;/a&gt;&lt;/h1&gt;
&lt;h1 id="modified-to-handle-sourcemap"&gt;Modified to handle sourceMap&lt;/h1&gt;
&lt;p&gt;formatSourcePosition = (frame, getSourceMapping) -&amp;gt;&lt;br /&gt;
fileName = undefined&lt;br /&gt;
    fileLocation = ''&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isNative&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;fileLocation&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &amp;quot;&lt;span class="n"&gt;native&lt;/span&gt;&amp;quot;
&lt;span class="k"&gt;else&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isEval&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;fileName = frame.getScriptNameOrSourceURL()&lt;br /&gt;
    fileLocation = "#{frame.getEvalOrigin()}, " unless fileName&lt;br /&gt;
    else&lt;br /&gt;
    fileName = frame.getFileName()&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="n"&gt;fileName&lt;/span&gt; &lt;span class="n"&gt;or&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt; &amp;quot;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;anonymous&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;quot;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;line = frame.getLineNumber()&lt;br /&gt;
    column = frame.getColumnNumber()&lt;/p&gt;
&lt;h1 id="check-for-a-sourcemap-position"&gt;Check for a sourceMap position&lt;/h1&gt;
&lt;p&gt;source = getSourceMapping fileName, line, column&lt;br /&gt;
    fileLocation =&lt;br /&gt;
    if source&lt;br /&gt;
    "#{fileName}:#{source&lt;span&gt;[0]&lt;/span&gt;}:#{source&lt;span&gt;[1]&lt;/span&gt;}, :#{line}:#{column}"&lt;br /&gt;
    else&lt;br /&gt;
    "#{fileName}:#{line}:#{column}"&lt;/p&gt;
&lt;p&gt;functionName = frame.getFunctionName()&lt;br /&gt;
isConstructor = frame.isConstructor()&lt;br /&gt;
    isMethodCall = not (frame.isToplevel() or isConstructor)&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;isMethodCall&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;methodName = frame.getMethodName()&lt;br /&gt;
    typeName = frame.getTypeName()&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;functionName&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;tp = as = ''&lt;br /&gt;
    if typeName and functionName.indexOf typeName&lt;br /&gt;
    tp = "#{typeName}."&lt;br /&gt;
    if methodName and functionName.indexOf(".#{methodName}") isnt functionName.length - methodName.length - 1&lt;br /&gt;
    as = " &lt;span&gt;[as #{methodName}]&lt;/span&gt;"&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&amp;quot;#&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;tp&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;#&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;functionName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;#&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;as&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;#&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;fileLocation&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;&amp;quot;
&lt;span class="k"&gt;else&lt;/span&gt;
&amp;quot;#&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;typeName&lt;/span&gt;&lt;span class="p"&gt;}.&lt;/span&gt;#&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;methodName&lt;/span&gt; &lt;span class="n"&gt;or&lt;/span&gt; &lt;span class="s"&gt;'&amp;lt;anonymous&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;#&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;fileLocation&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;&amp;quot;
&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;isConstructor&lt;/span&gt;
&amp;quot;&lt;span class="n"&gt;new&lt;/span&gt; #&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;functionName&lt;/span&gt; &lt;span class="n"&gt;or&lt;/span&gt; &lt;span class="s"&gt;'&amp;lt;anonymous&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;#&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;fileLocation&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;&amp;quot;
&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;functionName&lt;/span&gt;
&amp;quot;#&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;functionName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;#&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;fileLocation&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;&amp;quot;
&lt;span class="k"&gt;else&lt;/span&gt;
&lt;span class="n"&gt;fileLocation&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jameson Quinn</dc:creator><pubDate>Fri, 15 Mar 2013 00:42:00 -0000</pubDate><guid>https://sourceforge.net4d38e97e2ffe8c1dfb56331e4f43e5945beb2d0b</guid></item></channel></rss>