Commit Graph
77 Commits
Author SHA1 Message Date
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
José Valim 68c890e179 Move and and or operators to the new table 2013-06-23 13:18:25 +02:00
José Valim 6f73d7dbb9 Move comp_op to the new table 2013-06-23 13:18:25 +02:00
José Valim c2ac967123 Move all unary operators to new schema 2013-06-23 13:18:25 +02:00
José Valim dd573c9806 Initial work cleaning up op table 2013-06-23 13:18:25 +02:00
José Valim 2d8259b432 Support (x, y) when z, closes #1313 2013-06-22 18:53:18 +02:00
José Valim 67896b56c5 Ensure errors point to the proper -> clauses
This commit changes the -> clauses representation from:

    { :->, meta, list({ list(expr), expr }) }

To:

    { :->, meta, list({ list(expr), meta, expr }) }

Now clauses can store metadata, which allows us to provide
accurate reporting information.

Closes #1215
2013-06-16 17:27:14 +02:00
José Valim 99cdb412e3 Give higher precedence to |> than =~ 2013-05-29 03:19:45 +02:00
José Valim 0dcd5501f0 Fix a bug where unquote_splicing did not work on the left side of a stab op 2013-05-23 23:50:16 +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 9b0353a747 Improve error messages when there is a space in between function name and parenthesis 2013-05-21 12:57:22 +02:00
José Valim 05b650f373 Change preference of |> to support constructs like 1..5 |> Enum.to_list 2013-05-19 18:33:14 +02:00
José Valim 16e18240c6 Remove special case for implicit splicing inside quote 2013-05-01 00:29:40 -07:00
José Valim 61727e5c5d Ensure do/else|*/end are inlinable, closes #966 2013-04-30 14:47:14 -07:00
José Valim 20942ee329 Better support for Unicode lists 2013-01-28 11:43:25 -07:00
José Valim fef7ef7233 Ensure consistent use of stab operator in do/end, parens and fn/end, closes #780 2013-01-27 11:00:59 -07: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 4633c6449d Update LICENSE 2013-01-21 07:55:39 -07:00
alexrp 531e64c66a Add back /> as a deprecated operator.
This commit can simply be reverted when the operator is to be removed.
2013-01-08 01:12:15 +01:00
alexrp c9908a23dd The pipeline operator is now '|>'.
Fixes #718.
2013-01-07 23:38:55 +01:00