Commit Graph
62 Commits
Author SHA1 Message Date
José Valim 9540e9fd6a Raise correct error message for incomplete interpolation in heredoc, closes #9252 2019-07-30 18:36:41 +02:00
José Valim 81e5a57d51 Nest all terminator metadata under :end key 2019-05-09 10:28:18 +02:00
Eksperimental 99d919e0c8 Use "code point" instead of "codepoint" (#8774)
That's the term it is used in the Unicode standard.
2019-02-06 11:21:03 +01:00
José Valim beb596d37c Warn on unnecessary quotes (#7838) 2018-07-10 10:27:02 +02:00
Adrian Cruz 9707843134 Return error on bad hex escaping (#7809)
As discussed in #7270, it would help if we return error tuples
instead of exceptions. This PR does it for string unescaping.
2018-07-03 12:03:43 +02:00
José Valim 5edb1d2739 Add hints on mismatched do/end and others pairs
When you are working on large files and you add new code,
you may forget to add a `do` or an `end`. In those cases,
the error message usually points to the first `do` or the
last `end` in the file, which are usually far away from
the source of the error.

This pull request adds a simple heuristic based on the
indentation of the tokens, to try to provide hints of
where the source may be. Those hints are not deterministic
but they may be able to point users to the source of the
problem.

For example, in this case:

    defmodule MyApp do
      def one do
      # end

      def two do
      end
    end

we know that we now that `def two do` is happening on the
same indentation as `def one do`, which may mean that
`def one do` was not closed properly. We store this as a
hint in case the terminators do not match later.

Similarly, in the case below:

    defmodule MyApp do
      def one
      end

      def two do
      end
    end

The `end` on line 3 will end-up closing the defmodule `do`,
on line 1. Because their indentation do not match, it may
be that there is a missing `do`, where the `end` was supposed
to align.

Some basic testing show those heuristics work on the majority
of the cases, but we will only be sure when we have enough
feedback from the community.
2018-06-10 13:55:49 +02:00
José Valim d3a85bfd21 Remove end column information from tokens
If we want to store this information, we need to store it
alongside the end line, otherwise it is ambiguous.
2017-10-25 11:56:31 +02:00
José Valim ca7eb1706a Preserve escaped new lines in formatter, closes #6861 2017-10-11 13:18:49 +02:00
José Valim 2738594886 Add end_line to interpolation 2017-10-05 19:00:37 +02:00
José Valim 455c2c3f3b Rely on side effects for preserving comments
The previous implementation would not lead to parsing
errors in interpolations since code inside interpolation
is parsed immediately.
2017-10-05 13:27:25 +02:00
José Valim 9a33445c6c Do not unescape interpolation 2017-08-28 14:17:12 +02:00
Andrea Leopardi 8cd9b8a75a Change the format of tokens (#6495)
Right now, tokens are "{Token, Location}" or "{Token, Location, Value}".
This commit changes "Location" from "{Line, StartColumn, EndColumn}" to
"{Line, {StartColumn, EndColumn}, Meta}" where "Meta" can be anything.
This will be used for things such as storing the format of integers.
2017-08-22 21:12:30 +02:00
José Valim 0b0ab9f8ef Add Code.Identifier to hold shared identifier logic throughout Elixir 2017-08-22 13:22:26 +02:00
José Valim 482041e7ff Move tokenizer macros to tokenizer 2017-02-15 23:05:02 +01:00
Pedro Medeiros 0d2870f050 Fix some exported from case from erlang source (#5214)
Some erlang code were emiting a warning message when some
variables were defined inside the case statement.
2016-09-14 13:45:32 +02:00
José Valim 41c21f51cb Update TODOs and CHANGELOG
* Functionality won't be removed before v2.0
  * Features soft-deprecated in Elixir v1.2 will warn on v1.4
  * Features soft-deprecated in Elixir v1.3 will warn on v1.5
2016-06-02 21:21:24 +02:00
eksperimental 6da34e0225 Standardize unicode and friends (#4569)
* Unicode is a proper noun, so it should be capitalized

* Replace 'char data' with 'chardata'

* Correct use of a/an articles
2016-05-05 09:21:05 +02:00
eksperimental 4ceb41e71b Formmating: Add white space around vertical bar (#4507) 2016-04-25 00:55:49 +02:00
eksperimental bed9816549 Formatting: add white space after comma (#4491)
Standardizes the use of comma leaving a white space after it whenever applicable.

Note: It does not enforce this in quantifiers in regular expressions such as in: `x{1,3}`
2016-04-19 01:23:50 +02:00
José Valim ca856d774e Spell out our deprecation policy 2016-04-03 13:52:15 +02:00
José Valim a913f45442 Update TODOs 2016-04-03 13:00:48 +02:00
Daniel Perez 3bd1952de6 Do not escape new line when interpolation is disabled. Fix #4209. 2016-02-29 01:36:16 +09:00
José Valim a43e6fcdaa Control escaping of unicode sequences with ?u 2016-01-15 14:05:40 +01:00
José Valim 0bf58133c5 Deprecate soft-deprecated functionality 2016-01-02 11:04:21 +01:00
José Valim 3327854653 Support \u in strings and char lists for unicode mapping 2015-08-16 18:32:29 +02:00
eksperimental 61675c3ea8 Add space after comma: Format consistently 2015-03-17 22:55:27 +07:00
Alexander Ivanov b35a683647 Fix column counting in elixir_interpolation.erl 2015-01-06 16:57:00 +02:00
Alexander Ivanov c76a186687 Change location info format in tokenizer
Start column counting in tokenizer from 1, store location info in a tuple `{Line, BeginColumn, EndColumn}` instead of a list
2015-01-05 13:35:23 +02:00
Alexander Ivanov a288ddd326 Add column info in tokenizer, #2987
Add column info for each token in elixir_tokenizer.
Change the format of location info from `Line` to `[Line, BeginColumn,
EndColumn]`. Pass the current column after the current line in
`elixir_tokenizer:tokenize`. Reflect the change in related modules.
2015-01-05 03:34:53 +02:00
jw2013 b841f12b6e fix escaped terminatiors in sigil 2014-10-24 08:30:36 -07:00
José Valim 6a6ba9f50d Remove deprecated code 2014-08-02 22:35:57 +02:00
José Valim 6874eb7ce8 Deprecate octal and upcase char syntaxes 2014-07-29 20:33:42 +02:00
José Valim fc25f60718 Do not remove interpolation escape on uppercase sigils, closes #2512 2014-07-10 12:54:16 +02:00
José Valim e571218917 Sigils no longer balance start and end tokens, closes #2284 2014-06-24 13:17:43 +02:00
José Valim 56f15d9f4e Do not add spaces after { and before }
This makes the source code consistent with the result
returned by inspect/2.
2014-04-21 19:06:35 +02:00
Yuki Ito 013303a44e Support end-of-line backslash in quoted expressions
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2014-02-19 12:23:30 +01:00
José Valim 78def5da6e Raise better message on invalid or reserved codepoints 2013-12-25 14:44:01 +01:00
José Valim 67ac77fdb3 Sigils can now handle balanced tokens as in %s(f(o)o)
Closes #1480
2013-10-26 14:08:04 +02:00
José Valim 0171e201fb Move parsing from elixir_interpolations to elixir_parser 2013-10-26 13:46:01 +02:00
José Valim 404f77421a Refactor string interpolation to delegate to the tokenizer
This refactoring helps us clean up the interpolation code and
guarantee it works as expected since it goes under the same
tokenization rules. It also helps provide better sigil handling
(going to be improved in upcoming commits).
2013-10-25 13:19:47 +02:00
elegua e63e4d44a3 Fixed interpolation per issue 1758 2013-10-24 11:25:34 -07:00
José Valim 0510512375 Deprecate to_binary in favor of to_string
We also rename Binary.Chars to String.Chars.

As Binary.Chars was the protocol used for interpolation,
it is semantically correct to have a protocol that works
on strings, instead of raw binaries.
2013-08-22 12:19:30 +02:00
José Valim a013b39b8f Do not double escape strings inside interpolation, closes #1494 2013-07-25 14:34:13 +02:00
José Valim 2c98c0999d An Elixir module now translates to Elixir.Module instead of Elixir-Module 2013-05-23 14:36:56 +02:00
José Valim f7cad1cffc Improve error messages 2013-03-27 09:54:00 -06:00
José Valim 6024014482 Improve error message on unclosed interpolation/string, closes #794 2013-03-17 13:57:20 -06:00
José Valim 89cbe93bba The AST now allows metadata to be attached to each node
This means the second item in the AST is no longer an integer
(representing the line), but a keywords list. Code that relies
on the line information from AST or that manually generate AST
nodes need to be properly updated.
2013-01-21 15:42:03 -07:00
José Valim e2fde7699c Do not generate lowercase clause if lowercase == codepoint 2013-01-13 23:58:37 +01:00
José Valim bdc5f7ddd2 Also handle < and > inside interpolations 2013-01-10 14:29:45 +01:00
José Valim b9313340b7 Keep \377 and 0377 as the octal syntax, closes #737 2012-12-31 13:46:56 +01:00