coffee-script: `tokens`/`nodes` can now take options as well

This commit is contained in:
satyr 2010-10-09 04:27:05 +09:00
parent ebdd57a2fe
commit c5f922c5db
2 changed files with 8 additions and 8 deletions

View File

@ -27,11 +27,11 @@
throw err;
}
});
exports.tokens = function(code) {
return lexer.tokenize(code);
exports.tokens = function(code, options) {
return lexer.tokenize(code, options);
};
exports.nodes = function(code) {
return parser.parse(lexer.tokenize(code));
exports.nodes = function(code, options) {
return parser.parse(lexer.tokenize(code, options));
};
exports.run = function(code, options) {
var root;

View File

@ -33,14 +33,14 @@ exports.compile = compile = (code, options) ->
throw err
# Tokenize a string of CoffeeScript code, and return the array of tokens.
exports.tokens = (code) ->
lexer.tokenize code
exports.tokens = (code, options) ->
lexer.tokenize code, options
# Tokenize and parse a string of CoffeeScript code, and return the AST. You can
# then compile it by calling `.compile()` on the root, or traverse it by using
# `.traverse()` with a callback.
exports.nodes = (code) ->
parser.parse lexer.tokenize code
exports.nodes = (code, options) ->
parser.parse lexer.tokenize code, options
# Compile and execute a string of CoffeeScript (on the server), correctly
# setting `__filename`, `__dirname`, and relative `require()`.