From 9d4e06e8a8409191405a118acf2cfa1e02ef46ac Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Thu, 25 Feb 2010 18:42:35 -0500 Subject: [PATCH] moving -tr --tree to -n --nodes, and --no-wrap gives up its -n short flag. --- lib/coffee-script.js | 4 ++-- lib/command_line.js | 8 ++++---- src/coffee-script.coffee | 4 ++-- src/command_line.coffee | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/coffee-script.js b/lib/coffee-script.js index 769657dc..663fb159 100644 --- a/lib/coffee-script.js +++ b/lib/coffee-script.js @@ -38,11 +38,11 @@ return (parser.parse(lexer.tokenize(code))).compile(options); }; // Just the tokens. - exports.tokenize = function tokenize(code) { + exports.tokens = function tokens(code) { return lexer.tokenize(code); }; // Just the nodes. - exports.tree = function tree(code) { + exports.nodes = function nodes(code) { return parser.parse(lexer.tokenize(code)); }; // Activate CoffeeScript in the browser by having it compile and eval diff --git a/lib/command_line.js b/lib/command_line.js index 0d971eb3..74cd66a1 100644 --- a/lib/command_line.js +++ b/lib/command_line.js @@ -5,7 +5,7 @@ optparse = require('optparse'); CoffeeScript = require('coffee-script'); BANNER = "coffee compiles CoffeeScript source files into JavaScript.\n\nUsage:\n coffee path/to/script.coffee"; - SWITCHES = [['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-r', '--run', 'compile and run a CoffeeScript'], ['-o', '--output [DIR]', 'set the directory for compiled JavaScript'], ['-w', '--watch', 'watch scripts for changes, and recompile'], ['-p', '--print', 'print the compiled JavaScript to stdout'], ['-l', '--lint', 'pipe the compiled JavaScript through JSLint'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-e', '--eval', 'compile a string from the command line'], ['-n', '--no-wrap', 'compile without the top-level function wrapper'], ['-t', '--tokens', 'print the tokens that the lexer produces'], ['-tr', '--tree', 'print the parse tree that Jison produces'], ['-v', '--version', 'display CoffeeScript version'], ['-h', '--help', 'display this help message']]; + SWITCHES = [['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-r', '--run', 'compile and run a CoffeeScript'], ['-o', '--output [DIR]', 'set the directory for compiled JavaScript'], ['-w', '--watch', 'watch scripts for changes, and recompile'], ['-p', '--print', 'print the compiled JavaScript to stdout'], ['-l', '--lint', 'pipe the compiled JavaScript through JSLint'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-e', '--eval', 'compile a string from the command line'], ['--no-wrap', 'compile without the top-level function wrapper'], ['-t', '--tokens', 'print the tokens that the lexer produces'], ['-n', '--nodes', 'print the parse tree that Jison produces'], ['-v', '--version', 'display CoffeeScript version'], ['-h', '--help', 'display this help message']]; options = {}; sources = []; option_parser = null; @@ -82,9 +82,9 @@ o = options; try { if (o.tokens) { - return print_tokens(CoffeeScript.tokenize(code)); - } else if (o.tree) { - return puts(CoffeeScript.tree(code).toString()); + return print_tokens(CoffeeScript.tokens(code)); + } else if (o.nodes) { + return puts(CoffeeScript.nodes(code).toString()); } else { js = CoffeeScript.compile(code, compile_options()); if (o.run) { diff --git a/src/coffee-script.coffee b/src/coffee-script.coffee index e657001e..1474f99b 100644 --- a/src/coffee-script.coffee +++ b/src/coffee-script.coffee @@ -31,11 +31,11 @@ exports.compile: (code, options) -> (parser.parse lexer.tokenize code).compile(options) # Just the tokens. -exports.tokenize: (code) -> +exports.tokens: (code) -> lexer.tokenize code # Just the nodes. -exports.tree: (code) -> +exports.nodes: (code) -> parser.parse lexer.tokenize code # Activate CoffeeScript in the browser by having it compile and eval diff --git a/src/command_line.coffee b/src/command_line.coffee index 06fca5d7..d135bf2b 100644 --- a/src/command_line.coffee +++ b/src/command_line.coffee @@ -19,9 +19,9 @@ SWITCHES: [ ['-l', '--lint', 'pipe the compiled JavaScript through JSLint'] ['-s', '--stdio', 'listen for and compile scripts over stdio'] ['-e', '--eval', 'compile a string from the command line'] - ['-n', '--no-wrap', 'compile without the top-level function wrapper'] + [ '--no-wrap', 'compile without the top-level function wrapper'] ['-t', '--tokens', 'print the tokens that the lexer produces'] - ['-tr','--tree', 'print the parse tree that Jison produces'] + ['-n', '--nodes', 'print the parse tree that Jison produces'] ['-v', '--version', 'display CoffeeScript version'] ['-h', '--help', 'display this help message'] ] @@ -73,8 +73,8 @@ compile_scripts: -> compile_script: (source, code) -> o: options try - if o.tokens then print_tokens CoffeeScript.tokenize code - else if o.tree then puts CoffeeScript.tree(code).toString() + if o.tokens then print_tokens CoffeeScript.tokens code + else if o.nodes then puts CoffeeScript.nodes(code).toString() else js: CoffeeScript.compile code, compile_options() if o.run then eval js