Permalink
Browse files

some starting work on plugging into the coffee script compiler and ru…

…ntime
  • Loading branch information...
1 parent a56cb02 commit dabc75761c2b6308529f901ed14925c5e0b5f429 @maxtaco committed Nov 14, 2011
Showing with 19 additions and 3 deletions.
  1. +6 −3 src/coffee-script.coffee
  2. +13 −0 src/tame.coffee
View
@@ -10,8 +10,11 @@ fs = require 'fs'
path = require 'path'
{Lexer,RESERVED} = require './lexer'
{parser} = require './parser'
+tame = require './tame'
vm = require 'vm'
+astTamer = new tame.AstTamer
+
# TODO: Remove registerExtension when fully deprecated.
if require.extensions
require.extensions['.coffee'] = (module, filename) ->
@@ -34,7 +37,7 @@ exports.helpers = require './helpers'
exports.compile = compile = (code, options = {}) ->
{merge} = exports.helpers
try
- js = (parser.parse lexer.tokenize code).compile options
+ js = (astTamer.transform parser.parse lexer.tokenize code).compile options
return js unless options.header
catch err
err.message = "In #{options.filename}, #{err.message}" if options.filename
@@ -51,9 +54,9 @@ exports.tokens = (code, options) ->
# or traverse it by using `.traverseChildren()` with a callback.
exports.nodes = (source, options) ->
if typeof source is 'string'
- parser.parse lexer.tokenize source, options
+ astTamer.transform parser.parse lexer.tokenize source, options
else
- parser.parse source
+ astTamer.transform parser.parse source
# Compile and execute a string of CoffeeScript (on the server), correctly
# setting `__filename`, `__dirname`, and relative `require()`.
View
@@ -0,0 +1,13 @@
+# -*- mode: coffee; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
+exports.AstTamer = class AstTamer
+
+ constructor: (rest...) ->
+
+ transform: (x) ->
+ console.log ("transforming...")
+ x
+
+
+
+
+

0 comments on commit dabc757

Please sign in to comment.