mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
fixing the lexer to handle strings that end with a backslash character
This commit is contained in:
@@ -21,13 +21,13 @@ module CoffeeScript
|
|||||||
# Token matching regexes.
|
# Token matching regexes.
|
||||||
IDENTIFIER = /\A([a-zA-Z$_]\w*)/
|
IDENTIFIER = /\A([a-zA-Z$_]\w*)/
|
||||||
NUMBER = /\A(\b((0(x|X)[0-9a-fA-F]+)|([0-9]+(\.[0-9]+)?(e[+\-]?[0-9]+)?)))\b/i
|
NUMBER = /\A(\b((0(x|X)[0-9a-fA-F]+)|([0-9]+(\.[0-9]+)?(e[+\-]?[0-9]+)?)))\b/i
|
||||||
STRING = /\A(""|''|"(.*?)[^\\]"|'(.*?)[^\\]')/m
|
STRING = /\A(""|''|"(.*?)([^\\]|\\\\)"|'(.*?)([^\\]|\\\\)')/m
|
||||||
JS = /\A(``|`(.*?)[^\\]`)/m
|
JS = /\A(``|`(.*?)([^\\]|\\\\)`)/m
|
||||||
OPERATOR = /\A([+\*&|\/\-%=<>:!]+)/
|
OPERATOR = /\A([+\*&|\/\-%=<>:!]+)/
|
||||||
WHITESPACE = /\A([ \t]+)/
|
WHITESPACE = /\A([ \t]+)/
|
||||||
COMMENT = /\A(((\n?[ \t]*)?#.*$)+)/
|
COMMENT = /\A(((\n?[ \t]*)?#.*$)+)/
|
||||||
CODE = /\A(=>)/
|
CODE = /\A(=>)/
|
||||||
REGEX = /\A(\/(.*?)[^\\]\/[imgy]{0,4})/
|
REGEX = /\A(\/(.*?)([^\\]|\\\\)\/[imgy]{0,4})/
|
||||||
MULTI_DENT = /\A((\n([ \t]*)?)+)/
|
MULTI_DENT = /\A((\n([ \t]*)?)+)/
|
||||||
LAST_DENT = /\n([ \t]*)/
|
LAST_DENT = /\n([ \t]*)/
|
||||||
ASSIGNMENT = /\A(:|=)\Z/
|
ASSIGNMENT = /\A(:|=)\Z/
|
||||||
|
|||||||
8
test/fixtures/execution/test_literals.coffee
vendored
8
test/fixtures/execution/test_literals.coffee
vendored
@@ -17,4 +17,10 @@ print(neg is -1)
|
|||||||
func: =>
|
func: =>
|
||||||
return if true
|
return if true
|
||||||
|
|
||||||
print(func() is null)
|
print(func() is null)
|
||||||
|
|
||||||
|
|
||||||
|
str: "\\"
|
||||||
|
reg: /\\/
|
||||||
|
|
||||||
|
print(reg(str) and str is '\\')
|
||||||
Reference in New Issue
Block a user