mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-17 11:01:25 -05:00
moving print_tokens into the actual coffee-script module, so we can use it separately from the command-line
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Set up for both the browser and the server.
|
||||
if process?
|
||||
process.mixin require './nodes'
|
||||
path: require('path')
|
||||
path: require 'path'
|
||||
lexer: new (require('./lexer').Lexer)()
|
||||
parser: require('./parser').parser
|
||||
else
|
||||
@@ -42,6 +42,12 @@ exports.tokenize: (code) ->
|
||||
exports.tree: (code) ->
|
||||
parser.parse lexer.tokenize code
|
||||
|
||||
# Pretty-print a token stream.
|
||||
exports.print_tokens: (tokens) ->
|
||||
strings: for token in tokens
|
||||
'[' + token[0] + ' ' + token[1].toString().replace(/\n/, '\\n') + ']'
|
||||
strings.join(' ')
|
||||
|
||||
|
||||
#---------- Below this line is obsolete, for the Ruby compiler. ----------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user