Commit Graph
133 Commits
Author SHA1 Message Date
José Valim f7654bf66a Ensure we print unicode codepoints on errors, closes #3804 2015-09-29 15:03:55 +02:00
eksperimental ed5671b4f8 Standardize use of backticks and quotes; including Error messages and Title Case commands
This is a large commit that does the following:
* Removes backticks from messages and comments.
  All references to backticks have been replaced with double quotes everywhere the
  code is not interpreted as Markdown, (ie. anywhere outside documentation and
  markdown files, such as in code comments, or error messages).

* Variables in Exception messages are printed using `inspect`
  The way no-matching error message are printed, have changed because now we use inspect for printing
  variables. The following file and their respective test have been changed:
  - lib/elixir/lib/exception.ex
  - lib/elixir/lib/inspect/algebra.ex
  - lib/elixir/test/elixir/inspect_test.exs
  - lib/ex_unit/test/ex_unit/formatter_test.exs
  - lib/elixir/test/elixir/exception_test.exs

* Properly use Title Case for Mix, Git, Dializer

* Use backticks when citing a command

****************************************************
CONVENTION FOR RENAMING USING BACKTICKS AND QUOTES

https://github.com/elixir-lang/elixir/pull/3697#issuecomment-138811747

1. Backticks should never be printed in error messages, neither be included anywhere where Markdown code is not interpreted as such.

2. Do not use single quotes anywhere. We should favor double quotes everywhere, to avoid confusion

3. If you want to format something in error messages, use inspect. For example, if you want to show the dependency name and that is an atom, instead of the dependency "foo", let's show the dependency :foo. Less noise and may click better

4. Similarly, if you want to show something with double quotes, call inspect, as it handles escaping as well as the quotes

5. Things like "--all" just add verbosity, we can definitely read --all without ambiguity.

6. When using switches with a single hyphen (such as "-o"), we can make it explicit in the text: e.g. "... give the switch -o when choosing ..."

****************************************************
SHELL COMMANDS TO DETECT CODE BREAKING THE RULES

* Detect values surrounded by single-quotes where we want double-quotes.

    # regular variables
    ag "'#{"
    # constants or ENV variables
    ag "'[A-Z][A-Z0-9_-]+"
    # switches
    ag -i "(?<!(\[))'--?[a-z0-9][a-z0-9_-]+'"
    # atoms
    ag -i "(?<!(\[))':[a-z0-9][a-z0-9_-]+'"

    # DETECT BACKTICKS OUTSIDE DOCS
    ag "^\s+(?<!(#))#[^#\r\n]*\`" --ignore "*.md"
    ag '^\s+["%].*`' --ignore "*.md"
    ag -s '(raise|Error)\b(?!(`|/)).*\`'

* Spot mentions to running a command that is not using backticks:

    commands="elixir|elixirc|mix|iex|ex_doc|git|make|rebar|dialyzer|erl|rm|cd|mkdir|rmdir|ln|ls|pwd"
    actions="runs?|running|executes?|executing|types?|typing|enters?|entering|calls?|calling"
    ag '(?i)('${actions}')(?-i)\b[^`\r\n/]+[\ \t]+(?!(`))('${commands}')'
    ag '(?-i)\b(?!(`))('${commands}')[\ \t]+[^`\r\n/]+(?i)(commands?)'

* Spot where a command is mentioned:

    #commands="erlang|elixir|eex|iex|ex_unit|ex_doc|logger|elixirc|git|make|rebar|dialyzer|erl|rm|cd|mkdir|rmdir|ln|ls|pwd"
    commands="mix|elixirc|git|make|rebar|dialyzer|erl|rm|cd|mkdir|rmdir|ln|ls|pwd"
    ag -s '(?<!(\`))(?<!(\.))(?<!(/))(?<!(:))(?<!(_))\b('${commands}')\b(?!(:))(?!(\?))(?!(_))(?!(-))(?!(\.))(?!(\`))(?!(/))(?!(>))' \
    --ignore "*.erl" --ignore "*.yrl" --ignore "*.src"
2015-09-11 18:49:51 +07:00
José Valim c838bcd3cb Improve unexpected token error messages 2015-09-01 00:32:46 +02:00
ꗈ ꘐ ꗈ b8ee8c3e73 Raise if heredic terminator in invalid location
issue #3503

This will raise:
```elixir
foo = """
this """
```

This will not:
```elixir
foo = """
this \"\"\"
"""
```
2015-08-17 12:08:38 -07:00
José Valim c2813ac1ea Also perform new line checking with structs 2015-08-16 20:47:53 +02:00
José Valim 970f84382b Allow operators to work still after comments
Closes #3316
2015-08-16 20:11:11 +02:00
José Valim 4f265b12d6 Also fail on do after , and ;
Closes #3293
2015-08-16 19:49:04 +02:00
José Valim 84830d37ef Deprecate ?\x in favor of simply 0x 2015-08-16 18:00:10 +02:00
ꗈ ꘐ ꗈ add22f4b5b capture non-symbolic operators (&and/2, &not/1, &c.)
partial fix for issue #3486
pin operator  is a different issue and will take some more investgation to find the cause.
2015-08-11 11:25:26 -07:00
José Valim d235533b45 Remove reference to dynamic operators in table 2015-07-14 09:27:44 +02:00
José Valim 91ce4a6b57 Properly offset columns on dot 2015-06-24 19:04:54 +02:00
José Valim 577fcf5d30 Use the given length instead of calculating it 2015-06-24 18:53:31 +02:00
José Valim 2d4385a622 Fix reversed Line, Column in tokenizer 2015-06-24 18:19:52 +02:00
Roger Braun 196c750e8d Ensure that a digit follows the underscore in binary, octal, hex notations. 2015-06-13 19:20:59 +02:00
Roger Braun 0598f00aef Allows underscores in binary, octal and hex literals. 2015-06-12 12:55:34 +02:00
eksperimental 61675c3ea8 Add space after comma: Format consistently 2015-03-17 22:55:27 +07:00
José Valim c28bc3be3f Use identifier instead of name
Identifier is the correct term parser/tokenizer wise.
2015-02-28 19:33:46 +01:00
Or Neeman 5eed2991c8 Improve tokenization of identifiers and k: v keys
Closes #3113:
- Fix tokenization of `a@b: ` and `A!: `
- Add error for `a@b` (previously tokenized like `a @b`)
- Extend error for `a:b` to cover `a:+`, etc.
- Unify tokenization of upper- and lower-case `k: v` keys
- Fix end-column value for `a: `
- Add tests as appropriate
2015-02-28 12:07:14 -06:00
Xavier Defrang 7381cbee02 Invert the order of non matching token messages (closes #2993) 2015-01-10 09:40:44 +01:00
Alexander Ivanov b35a683647 Fix column counting in elixir_interpolation.erl 2015-01-06 16:57:00 +02:00
Alexander Ivanov 3177e2ebd0 Count \\ as just one character in column info in tokenizer 2015-01-06 14:49:23 +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
James Brennan 827f9ad873 Allow U (upper case u) as an option for sigil_r 2014-09-14 18:23:33 -07:00
José Valim 843706e36e Add free operators
<<~, ~>>, <~, ~>, <~>, <|>
2014-09-07 12:42:10 +02:00
José Valim 172bfdb128 Revert "Merge pull request #2702 from alexrp/master"
<~ is already a valid expression in Elixir.

This reverts commit 2c741ec6ae, reversing
changes made to 12a457829f.
2014-09-07 12:12:35 +02:00
Alex Rønne Petersen c8bcd89c7c Introduce new operators intended for use by parser combinator libraries.
The expected definitions (which are by no means required) in
parser combinator speak are:

* `p  ~>> f`   =  `bind(p, f)`
* `p1 ~>  p2`  =  `pair_right(p1, p2)`
* `p1 <~  p2`  =  `pair_left(p1, p2)`
* `p1 <~> p2`  =  `pair_both(p1, p2)`
* `p  |~> f`   =  `map(p, f)`
* `1p <|> p2`  =  `either(p1, p2)`
2014-09-02 01:57:50 +02:00
Eric Meadows-Jönsson c6fa951520 Better error message on nbsp 2014-08-19 17:00:58 +02:00
José Valim e6e71675ac Make a distinction between eol and ; 2014-08-12 16:27:45 +02:00
José Valim 4d763846c3 Ensure code escape \ works in IEx 2014-08-11 10:05:24 +02:00
Aleksei Magusev c6f27541c1 Bind value to proper name in elixir_tokenizer 2014-08-10 19:41:13 +04:00
José Valim 2d9c3fb6f0 Print warnings when used ? with characters with escape codes
Closes #2640
2014-08-08 11:13:13 +02: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
Yuki Ito 81ed03ffb2 Parse unary/binary operators regardless of number of spaces
closes #2534.
2014-07-26 20:03:38 +09:00
José Valim 058b157b36 Remove deprecated features and deprecate soft ones 2014-07-12 16:23:17 +02:00
José Valim 28264c6792 Improvements to the operator table
* |>, <<<, >>> and ^^^ were made left associative

  * <, >, <=, >= were given higher precedence than
    comparison ones (==, !=, etc)

  * xor is deprecated
2014-06-29 16:18:33 +02:00
José Valim b4415f2a14 Change precedence of & to not special case / 2014-06-28 11:16:51 +02:00
José Valim f76c8fec7b Support E in scientific notation for floats 2014-06-05 13:18:25 +02:00
José Valim 55e885f5c5 Ensure we don't leak erlang terms on failure, closes #2303 2014-05-21 12:44:12 +02:00
José Valim b342739dba Tag wrong heredoc start as SyntaxError instead of TokenMissingError 2014-05-20 20:25:31 +02:00
José Valim dc9803de6d Remove inlist and inbits from keywords list 2014-05-19 23:12:45 +02:00
José Valim 5e34d0a7f1 Allow h +/1 as valid syntax 2014-05-13 14:21:51 +02:00
José Valim 64c5acb923 Fix syntax error on .%, closes #2245 2014-05-07 19:36:31 +02:00
José Valim 31c34dc04e Ensure we only allow horizontal space in heredocs 2014-04-24 20:57:06 +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
José Valim d33463dcd5 Unify precedence of when, :: and | 2014-03-31 12:28:33 +02:00
José Valim 14d2ce460e Also raise proper error on keywords followed by numbers, closes #2091 2014-03-18 12:07:39 +01:00
José Valim ecd5b3d8ef Ensure do can be at the start of its own line, closes #2053 2014-03-13 09:44:01 -07:00
Eric Meadows-Jönsson 04e774a4ba Support interpolation in keyword list atoms
key = "foo"
    ["#{key}": :value]
2014-03-05 16:43:26 +01:00