mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
fixing the lexer to handle strings that end with a backslash character
This commit is contained in:
parent
3e33b4a618
commit
cf7079a379
2 changed files with 10 additions and 4 deletions
|
@ -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/
|
||||||
|
|
6
test/fixtures/execution/test_literals.coffee
vendored
6
test/fixtures/execution/test_literals.coffee
vendored
|
@ -18,3 +18,9 @@ func: =>
|
||||||
return if true
|
return if true
|
||||||
|
|
||||||
print(func() is null)
|
print(func() is null)
|
||||||
|
|
||||||
|
|
||||||
|
str: "\\"
|
||||||
|
reg: /\\/
|
||||||
|
|
||||||
|
print(reg(str) and str is '\\')
|
Loading…
Add table
Reference in a new issue