adding newline escaping, with tests

This commit is contained in:
Jeremy Ashkenas
2009-12-26 09:29:03 -08:00
parent 2a1fc4b1b7
commit 08dddb27a0
4 changed files with 18 additions and 4 deletions

View File

@@ -130,11 +130,13 @@ module CoffeeScript
# We treat all other single characters as a token. Eg.: ( ) , . !
# Multi-character operators are also literal tokens, so that Racc can assign
# the proper order of operations. Multiple newlines get merged together.
# Use a trailing \ to escape newlines.
def literal_token
value = @chunk[NEWLINE, 1]
if value
@line += value.length
token("\n", "\n") unless last_value == "\n"
token("\n", "\n") unless ["\n", "\\"].include?(last_value)
@tokens.pop if last_value == "\\"
return @i += value.length
end
value = @chunk[OPERATOR, 1]