Skip to content

Instantly share code, notes, and snippets.

View StanAngeloff's full-sized avatar

Stan Angeloff StanAngeloff

View GitHub Profile
{ get a: -> @a }
{
get a: function a() {
return this.a;
}
};
diff --git a/src/grammar.coffee b/src/grammar.coffee
index 81d5b04..69df6d8 100644
--- a/src/grammar.coffee
+++ b/src/grammar.coffee
@@ -135,12 +135,25 @@ grammar: {
o "Assignable ASSIGN Expression", -> new AssignNode $1, $3
]
- # Assignment when it happens within an object literal. The difference from
- # the ordinary **Assign** is that these allow numbers and strings as keys.
obj: {
i_am_a_named_fn: -> yes
i_still_have_a_name: -> (yes)
i_have_no_name: (-> yes)
}
template recoverable: ->
args: arguments[0].flatten()
"${args[0].value}: ${ utility 'recoverable' } <- ${args[0].value}"
my_async_fn: (err, result) ->
.. code here ..
recoverable my_async_fn
[left: right]: bag
diff --git a/src/rewriter.coffee b/src/rewriter.coffee
index ec07bd4..6210088 100644
--- a/src/rewriter.coffee
+++ b/src/rewriter.coffee
@@ -54,10 +54,14 @@ exports.Rewriter: class Rewriter
adjust_comments: ->
@scan_tokens (prev, token, post, i) =>
return 1 unless token[0] is 'COMMENT'
+ before: @tokens[i - 2]
after: @tokens[i + 2]
diff --git a/src/lexer.coffee b/src/lexer.coffee
index 1fba057..59c0595 100644
--- a/src/lexer.coffee
+++ b/src/lexer.coffee
@@ -199,7 +199,7 @@ exports.Lexer: class Lexer
prev: @prev(2)
size: indent.match(LAST_DENTS).reverse()[0].match(LAST_DENT)[1].length
next_character: @chunk.match(MULTI_DENT)[4]
- no_newlines: next_character is '.' or @unfinished()
+ no_newlines: next_character is '.' or next_character is '+' or @unfinished()
# This is at the start of the current Lexer.
# Import the helpers we need.
helpers: require('./helpers').helpers
include: helpers.include
count: helpers.count
starts: helpers.starts
compact: helpers.compact
balanced_string: helpers.balanced_string
if (!(cond)) {
expression;
}
vs.
if ( ! (cond)) {
expression;
}
obj: {
_value: []
get value: -> @_value
set value: (val) -> @_value: val
one: (n) -> n.concat [n[-1] + 1]
two: (n) -> n.concat [n[-1] + 2]
}