1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00
jashkenas--coffeescript/test
Simon Lydell 0dcff507fb Refactor interpolation (and string and regex) handling in lexer
- Fix #3394: Unclosed single-quoted strings (both regular ones and heredocs)
  used to pass through the lexer, causing a parsing error later, while
  double-quoted strings caused an error already in the lexing phase. Now both
  single and double-quoted unclosed strings error out in the lexer (which is the
  more logical option) with consistent error messages. This also fixes the last
  comment by @satyr in #3301.

- Similar to the above, unclosed heregexes also used to pass through the lexer
  and not error until in the parsing phase, which resulted in confusing error
  messages. This has been fixed, too.

- Fix #3348, by adding passing tests.

- Fix #3529: If a string starts with an interpolation, an empty string is no
  longer emitted before the interpolation (unless it is needed to coerce the
  interpolation into a string).

- Block comments cannot contain `*/`. Now the error message also shows exactly
  where the offending `*/`. This improvement might seem unrelated, but I had to
  touch that code anyway to refactor string and regex related code, and the
  change was very trivial. Moreover, it's consistent with the next two points.

- Regexes cannot start with `*`. Now the error message also shows exactly where
  the offending `*` is. (It might actually not be exatly at the start in
  heregexes.) It is a very minor improvement, but it was trivial to add.

- Octal escapes in strings are forbidden in CoffeeScript (just like in
  JavaScript strict mode). However, this used to be the case only for regular
  strings. Now they are also forbidden in heredocs. Moreover, the errors now
  point at the offending octal escape.

- Invalid regex flags are no longer allowed. This includes repeated modifiers
  and unknown ones. Moreover, invalid modifiers do not stop a heregex from
  being matched, which results in better error messages.

- Fix #3621: `///a#{1}///` compiles to `RegExp("a" + 1)`. So does
  `RegExp("a#{1}")`. Still, those two code snippets used to generate different
  tokens, which is a bit weird, but more importantly causes problems for
  coffeelint (see clutchski/coffeelint#340). This required lots of tests in
  test/location.coffee to be updated. Note that some updates to those tests are
  unrelated to this point; some have been updated to be more consistent (I
  discovered this because the refactored code happened to be seemingly more
  correct).

- Regular regex literals used to erraneously allow newlines to be escaped,
  causing invalid JavaScript output. This has been fixed.

- Heregexes may now be completely empty (`//////`), instead of erroring out with
  a confusing message.

- Fix #2388: Heredocs and heregexes used to be lexed simply, which meant that
  you couldn't nest a heredoc within a heredoc (double-quoted, that is) or a
  heregex inside a heregex.

- Fix #2321: If you used division inside interpolation and then a slash later in
  the string containing that interpolation, the division slash and the latter
  slash was erraneously matched as a regex. This has been fixed.

- Indentation inside interpolations in heredocs no longer affect how much
  indentation is removed from each line of the heredoc (which is more
  intuitive).

- Whitespace is now correctly trimmed from the start and end of strings in a few
  edge cases.

- Last but not least, the lexing of interpolated strings now seems to be more
  efficient. For a regular double-quoted string, we used to use a custom
  function to find the end of it (taking interpolations and interpolations
  within interpolations etc. into account). Then we used to re-find the
  interpolations and recursively lex their contents. In effect, the same string
  was processed twice, or even more in the case of deeper nesting of
  interpolations. Now the same string is processed just once.

- Code duplication between regular strings, heredocs, regular regexes and
  heregexes has been reduced.

- The above two points should result in more easily read code, too.
2015-01-04 07:47:09 +01:00
..
importing renaming import test files to avoid risking the disfavor of .gitignore 2013-06-02 10:57:18 +04:00
arrays.coffee renaming wordy test titles. 2011-04-23 13:35:15 -04:00
assignment.coffee Added expansion to destructuring 2014-01-24 16:00:34 +00:00
booleans.coffee renaming wordy test titles. 2011-04-23 13:35:15 -04:00
classes.coffee Fixes #3232 -- Tag all class properties static 2013-11-15 03:44:26 +01:00
cluster.coffee Fixes #2737, fix fork() for both .js and .coffee, revised. 2013-03-18 11:46:54 +08:00
comments.coffee Added test for jashkenas/coffee-script#3638 2014-09-17 15:02:18 +04:00
compilation.coffee Improve HEREDOC regexp 2013-11-28 16:46:00 +01:00
comprehensions.coffee Fix expansion in destructuring inside comprehensions 2014-01-24 18:20:45 +00:00
control_flow.coffee Fix multiple postfix conditionals 2013-12-17 03:31:19 +01:00
error_messages.coffee Refactor interpolation (and string and regex) handling in lexer 2015-01-04 07:47:09 +01:00
eval.coffee whitespace cleanup 2011-12-24 07:04:34 -05:00
exception_handling.coffee #2900 -- parameter-less catch clause. 2013-04-12 17:50:45 +02:00
formatting.coffee Fixes chaining after inline implicit objects 2014-01-26 22:11:10 +00:00
function_invocation.coffee Fix #1069. Non-callable literals shouldn't compile 2013-04-23 04:28:45 +02:00
functions.coffee Add tests for the optimization of trailing return statements 2014-02-06 09:21:35 -05:00
generators.coffee added tests for yield in switch & for loop expressions 2014-11-21 23:14:53 +01:00
helpers.coffee Quick spelling fixes 2014-08-26 20:41:32 -05:00
importing.coffee renaming import test files to avoid risking the disfavor of .gitignore 2013-06-02 10:57:18 +04:00
interpolation.coffee Refactor interpolation (and string and regex) handling in lexer 2015-01-04 07:47:09 +01:00
javascript_literals.coffee finished reorganizing test suite 2011-01-03 04:17:00 -05:00
literate.litcoffee Fixes tabbed code test in literate 2013-05-15 10:30:20 +01:00
location.coffee Refactor interpolation (and string and regex) handling in lexer 2015-01-04 07:47:09 +01:00
numbers.coffee fixes #2224: various issues related to number lexing 2012-03-27 21:31:20 -04:00
objects.coffee Fix for declarations in object literals 2014-01-26 04:41:30 +00:00
operators.coffee fixes #3363: modulo operator evaluation order 2014-02-08 20:56:34 -06:00
option_parser.coffee OptionParser and related tests needed a cleanup 2012-01-25 19:47:03 -05:00
ranges.coffee test for #1409 2011-06-02 01:49:28 -04:00
regexps.coffee Refactor interpolation (and string and regex) handling in lexer 2015-01-04 07:47:09 +01:00
repl.coffee Use separate variable for fd used to read history file; use string interpolation to print code lines; do not use unit test to remove temporary file and instead use a process exit event handler 2013-03-25 09:49:59 -07:00
scope.coffee Do not rely on properties order in scope tests 2014-05-21 16:40:44 +02:00
slicing_and_splicing.coffee Fix #2953. Method calls on splice endpoints 2013-04-23 05:42:37 +02:00
soaks.coffee Fix #1069. Non-callable literals shouldn't compile 2013-04-23 04:28:45 +02:00
sourcemap.coffee Quick spelling fixes 2014-08-26 20:41:32 -05:00
strict.coffee Refactor interpolation (and string and regex) handling in lexer 2015-01-04 07:47:09 +01:00
strings.coffee Refactor interpolation (and string and regex) handling in lexer 2015-01-04 07:47:09 +01:00
test.html encode unicode src, test added 2013-03-21 09:04:23 +08:00