moving print_tokens into the actual coffee-script module, so we can use it separately from the command-line

This commit is contained in:
Jeremy Ashkenas
2010-02-15 18:09:01 -05:00
parent e7291f57ba
commit 9c3040b704
4 changed files with 23 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
(function(){
var BANNER, SWITCHES, WATCH_INTERVAL, coffee, compile, compile_scripts, lint, option_parser, options, optparse, parse_options, path, posix, sources, tokenize, usage, version, write_js;
var BANNER, SWITCHES, WATCH_INTERVAL, coffee, compile, compile_scripts, lint, option_parser, options, optparse, parse_options, path, posix, sources, usage, version, write_js;
posix = require('posix');
path = require('path');
coffee = require('coffee-script');
@@ -69,7 +69,7 @@
return posix.cat(source).addCallback(function(code) {
var js;
if (opts.tokens) {
puts(tokenize(code));
puts(coffee.print_tokens(coffee.tokenize(code)));
} else if (opts.tree) {
puts(coffee.tree(code).toString());
} else {
@@ -97,14 +97,6 @@
return posix.write(fd, js);
});
};
// Pretty-print the token stream.
tokenize = function tokenize(code) {
var strings;
strings = coffee.tokenize(code).map(function(token) {
return '[' + token[0] + ' ' + token[1].toString().replace(/\n/, '\\n') + ']';
});
return strings.join(' ');
};
// Pipe compiled JS through JSLint (requires a working 'jsl' command).
lint = function lint(js) {
var jsl;