Commit Graph
96 Commits
Author SHA1 Message Date
Eric Meadows-Jönsson d868b4d066 Do not wrap single lists in :__block__ 2014-04-27 22:26:14 +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 6624f31472 Merge branch 'jv-char-data'
Conflicts:
	lib/eex/lib/eex/tokenizer.ex
	lib/elixir/lib/file.ex
	lib/elixir/lib/kernel.ex
	lib/elixir/lib/record/extractor.ex
	lib/elixir/lib/string.ex
	lib/ex_unit/lib/ex_unit/doc_test.ex
	lib/mix/lib/mix/archive.ex
	lib/mix/lib/mix/dep/fetcher.ex
	lib/mix/lib/mix/dep/umbrella.ex
2014-04-21 08:38:48 +02:00
José Valim d33463dcd5 Unify precedence of when, :: and | 2014-03-31 12:28:33 +02:00
Eric Meadows-Jönsson 04e774a4ba Support interpolation in keyword list atoms
key = "foo"
    ["#{key}": :value]
2014-03-05 16:43:26 +01:00
José Valim 6a725ab91f Provide List.from_char_data! and String.from_char_data! 2014-02-23 11:04:24 +01:00
José Valim 128d82fde6 Add defstruct and allow unquoting inside maps/structs 2014-02-19 22:35:09 +01:00
José Valim da1541c791 Implement access and slightly reorganize tests 2014-02-05 16:11:53 +01:00
José Valim de71ecf195 Remove outdated default args syntax 2014-02-05 14:58:28 +01:00
José Valim ffdf3d32b2 Ensure multiple kw args with pipe 2014-02-04 22:30:51 +01:00
José Valim 1fa74df6c7 Support map updates 2014-02-04 20:54:15 +01:00
José Valim cb9c17c025 Allow %{ foo => bar } 2014-02-04 18:00:04 +01:00
José Valim 923eeb9602 Unify max_expr to avoid duplication 2014-02-04 17:22:43 +01:00
José Valim c5ff2d1dcf Basic support for maps in the grammar 2014-02-03 20:18:01 +01:00
José Valim c65dcc9b19 Refactor grammar and unify base_expr into max_expr 2014-02-03 17:52:27 +01:00
José Valim 2b12cb4a7e Remove unecessary lexical check in parser 2014-01-30 22:04:39 +01:00
José Valim 05cd7f170f Fix list with keywords expansion
The list `[1, 2, three: :four]` now correctly expands
to `[1, 2, {:three, :four}]`.
2014-01-28 20:59:07 +01:00
José Valim 0d4655d1db Generalize unary operators followed by int have higher precedence 2014-01-28 19:54:09 +01:00
José Valim fe2e4a1010 Move from // to \\ 2014-01-28 10:50:00 +01:00
José Valim ec94c93b24 Remove ** from operators list for now 2014-01-20 12:24:22 +01:00
José Valim f671e1204c Change precedence of <- to be the same as other generators 2014-01-16 20:08:55 +01:00
José Valim 53b68887b6 Invert the precedence of | and when
Although this adds some drawbacks when it comes to typespecs,
it prepares us for when we have named patterns.
2014-01-11 16:52:46 +01:00
José Valim 96a1628033 Unify precedence of ++, --, **, .., <> ops 2014-01-09 01:06:34 +01:00
José Valim ade26dedd8 Work on Elixir expressions rather than forms 2013-12-28 11:47:44 +01:00
José Valim 51aef55c83 Change how -> is represented in the AST
The previous representation was very hard to compose
and very often required the AST nodes to be created
manually.

The current approach is easier to compose because
the node is represented as any other operator as long
as it is wrapped in parentheses.

For example, imagine we have pairs of patterns and
the code to be executed for that pattern, and we want
to inject them into a case. It can now be writen as:

    pairs = Enum.map pairs, fn { pattern, expr } ->
      quote do: (unquote(pattern) -> unquote(expr))
    end

    quote do
      case unquote(condition), do: unquote(pairs)
    end

Compare to the previous implementation:

    pairs = Enum.map pairs, fn { pattern, expr } ->
      { [pattern], [], expr }
    end

    pairs = { :->, [], pairs }

    quote do
      case unquote(condition), do: unquote(pairs)
    end
2013-12-23 16:10:33 +01:00
Eric Meadows-Jonsson a711bef57f Dont require [] for keyword list operand in when/2 2013-12-13 13:12:25 +01:00
José Valim f62c26b9b6 Ensure record aliases in the same quote can be accessed, closes #1915
This commit also simplifies macro expansion for both imports and aliases
to always give higher preference to the macro environment rather than
the caller one, if such is available. The deal is to simplify both the
code and understanding of how macros work.
2013-12-07 20:01:11 +01:00
Eric Meadows-Jonsson f125d19854 Move typespec guards to end of spec
Moves precedence of `when` to be lower than `::`.
2013-11-11 10:08:24 +01:00
José Valim 0171e201fb Move parsing from elixir_interpolations to elixir_parser 2013-10-26 13:46:01 +02:00
José Valim 0b3c91bf6d Do not wrap fn -> end in do keyword
The previous AST came from the fact `fn -> end` was a shortcut
for `function do ... end`. But now since the original no longer
exists, it seems saner to update `fn -> end` AST.
2013-10-24 22:38:25 +02:00
José Valim 997a0857c3 Avoid flattening in access[...], closes #1763 2013-10-18 14:54:49 +02:00
José Valim 488344839a Allow any function identifier as a variable, closes #1649 2013-08-25 10:28:55 -03:00
José Valim a6cdc835a1 No need to wrap quote do: nil in a block 2013-08-23 11:22:11 +02: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 a696b9cc11 Update Macro.to_string comments 2013-08-15 14:27:53 +02:00
José Valim db47bd56b4 Add Path.relative_to_cwd and rely on it when generating stacktraces 2013-08-14 12:36:54 +02:00
José Valim cea31f69dc Review and deprecate list <-> binary conversion 2013-08-14 11:16:37 +02:00
José Valim a154a9e99a Allow &1.foo syntax inside capture 2013-07-31 16:03:52 +02:00
José Valim b5428adda6 Add &local/arity and &Remote.fun/arity 2013-07-31 12:58:07 +02:00
José Valim abb2ada8b1 Make & an unary operator 2013-07-29 14:08:33 +02:00
José Valim 7ad7847596 Rearrange how ambiguous ops are handled, closes #1378 2013-07-06 12:32:22 +02:00
José Valim a6f8e178c0 Consistently allow empty expressions on both side of operators 2013-07-04 20:29:39 +02:00
José Valim ebe522ec50 Tighten up the grammar rules regarding parentheses omission
Prior to this commit, Elixir allowed too many ambiguous calls
by ommitting the parentheses:

    do_something 1, is_list [], 3
    [1, is_atom :foo, 3]

Both cases above would lead to a compilation error, as an attempt
to call is_list/2 and is_atom/2 would happen. Those examples will
now raise a syntax error, pointing to the ambiguous location.

We have disallowed such examples throughout the language with
the exception of one argument calls:

    assert is_list []

Examples as above are extremely frequent and were kept as is.
2013-07-04 18:48:55 +02:00
José Valim 62527cae9c Small clean up on parser file 2013-07-03 15:05:08 +02:00
José Valim 7ba5733496 No need to wrap lists in blocks 2013-06-26 21:53:33 +02:00
José Valim c6284557e7 Rename sigils from __ to sigil_$, closes #1301 2013-06-23 20:38:37 +02:00
José Valim 903aa60fec Finish operator table clean up 2013-06-23 13:18:25 +02:00
José Valim 969bc968ee Move ++, --, ** and // to new table 2013-06-23 13:18:25 +02:00
José Valim e941d78daf Move operator table clean up 2013-06-23 13:18:25 +02:00
José Valim 8d3475825b Group arrow-like ops together 2013-06-23 13:18:25 +02:00