Skip to content

Commit 12fdcce

Browse files
committed
Add uniced option.
1 parent e722cec commit 12fdcce

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/coffee-script.coffee

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,14 @@ exports.tokens = withPrettyErrors (code, options) ->
9191
# return the AST. You can then compile it by calling `.compile()` on the root,
9292
# or traverse it by using `.traverseChildren()` with a callback.
9393
exports.nodes = withPrettyErrors (source, options) ->
94+
console.log 'uniced', options.uniced
9495
if typeof source is 'string'
95-
iced_transform(parser.parse(lexer.tokenize(source, options)), options)
96+
result = parser.parse lexer.tokenize(source, options)
9697
else
97-
iced_transform(parser.parse(source),options)
98+
result = parser.parse source
99+
if not options.uniced
100+
result = iced_transform result, options
101+
return result
98102

99103
# Compile and execute a string of CoffeeScript (on the server), correctly
100104
# setting `__filename`, `__dirname`, and relative `require()`.

src/command.coffee

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ SWITCHES = [
5151
['-s', '--stdio', 'listen for and compile scripts over stdio']
5252
['-l', '--literate', 'treat stdio as literate style coffee-script']
5353
['-t', '--tokens', 'print out the tokens that the lexer/rewriter produce']
54+
['-u', '--uniced', 'print out the uniced parse tree that the parser produces']
5455
['-v', '--version', 'display the version number']
5556
['-w', '--watch', 'watch scripts for changes and rerun commands']
5657
['-I', '--runtime [WHICH]', "how to include the iced runtime, one of #{runtime_modes_str}; default is 'node'" ]
@@ -168,8 +169,9 @@ compileScript = (file, input, base = null) ->
168169
CoffeeScript.emit 'compile', task
169170
if o.tokens
170171
printTokens CoffeeScript.tokens t.input, t.options
171-
else if o.nodes
172-
printLine CoffeeScript.nodes(t.input, t.options).toString().trim()
172+
else if o.nodes or o.uniced
173+
printLine CoffeeScript.nodes(
174+
t.input, t.options, o.uniced).toString().trim()
173175
else if o.run
174176
CoffeeScript.register()
175177
CoffeeScript.run t.input, t.options
@@ -403,6 +405,7 @@ compileOptions = (filename, base) ->
403405
sourceMap: opts.map
404406
runtime : opts.runtime
405407
runforce : opts.runforce
408+
uniced: opts.uniced
406409
}
407410
if filename
408411
if base

0 commit comments

Comments
 (0)