Commit Graph

622 Commits

Author SHA1 Message Date
Kevin Atkinson
5f6a1159bb Fix q-q so that non-expression q-q actually work when there is embed anti-q. 2012-02-03 20:54:00 -07:00
Kevin Atkinson
a2dde9a692 Allow anti-quotes to also be ast::ty rather than just ast::expr. 2012-02-03 20:41:49 -07:00
Kevin Atkinson
6dcd12dc22 Implement quasi-quoting of multiple syntatic categories. 2012-02-03 20:41:49 -07:00
Kevin Atkinson
35a199c036 Formatting cleanups. 2012-02-03 20:41:49 -07:00
Kevin Atkinson
9090a5c03b Store info about file "substr".
That is when a string that is part of a file needs to be parsed for a
reason, record that the string is a substr of the file rather than
using "<anon>" or "-" as the file name.  This will eventually allow
pointing to the right location, for now it just uses a more
meaningful string for the filename.
2012-02-03 20:41:49 -07:00
Kevin Atkinson
4d71285c93 Implement quasi-quotes in more macro form: #ast{...}.
The #(...) form is still supported for now.
2012-02-03 20:41:49 -07:00
Kevin Atkinson
1c91fb4d91 Don't rely on filename to get a file from the filemap
as there may be more than one filemap with the same filename (in the
case of stdin for instance).  This involved storing a pointer to the
filemap rather than the filename in location info such as
codemap::pos.
2012-02-03 20:41:49 -07:00
Kevin Atkinson
4616117f17 Bug fix in lookup_byte_offset. 2012-02-03 20:41:49 -07:00
Kevin Atkinson
da74a7f9ca Make macro arg optional in syntax, again untested. 2012-02-03 20:41:48 -07:00
Kevin Atkinson
5ea04c65c1 Add support for recognizing macro body, completely untested. 2012-02-03 20:41:48 -07:00
Kevin Atkinson
e76fdeb3a6 Change the type for the macro body to also store the span.
Note: the body is the part of the macro syntax between the {}.
2012-02-03 20:41:48 -07:00
Kevin Atkinson
099290bc73 When replacing $(...) with $0 preserve spacing for better error messages.
That is:
  x + $(foo) + y
becomes:
  x + $0     + y
not:
  x + $0 + y
2012-02-03 20:41:37 -07:00
Kevin Atkinson
c0f9073557 Expand result of quasi-quote. 2012-02-03 20:39:00 -07:00
Kevin Atkinson
67e961c17f Implement anti-quotes. 2012-02-03 20:38:44 -07:00
Kevin Atkinson
477714f08e Implement "replace" function. 2012-02-03 20:28:12 -07:00
Kevin Atkinson
485e489ba2 Implement basic quasi-quoter. No anti-quotes yet. 2012-02-03 20:28:11 -07:00
Kevin Atkinson
98450d0dad Rename AST builders to use uniform naming scheme. Also add a few more. 2012-02-03 20:28:11 -07:00
Kevin Atkinson
5ef53382ae Add support for parsing quasi-quotes, doesn't do anything useful yet. 2012-02-03 20:23:49 -07:00
Kevin Atkinson
75edd9ff69 Move useful ast building functions into their own module. 2012-02-03 17:48:17 -08:00
Kevin Atkinson
9dcb674525 Add function to get a code snippet from a span,
and also to get the byte offset within a string from a span chpos.
2012-02-03 17:48:17 -08:00
Brian Anderson
2b67de06c8 rustdoc: Add support for type items 2012-02-01 22:41:54 -08:00
Kevin Cantu
8f367ebfeb Rename (again) str::unsafe::slice -> str::unsafe::slice_bytes and
str::unsafe::safe_slice -> str::unsafe::slice_bytes_safe_range
2012-02-01 21:56:53 -08:00
Kevin Cantu
fceec03da0 Propagating unsafe::slice 3 2012-02-01 21:56:53 -08:00
Kevin Cantu
6156bc56cb Propagating unsafe::slice 2 2012-02-01 21:56:53 -08:00
Niko Matsakis
196d69beb2 make boxes self-describing (fixes #1493)" (take 2)
this will be used to generate a new snapshot.
2012-02-01 18:52:08 -08:00
Niko Matsakis
3116643806 Revert "make boxes self-describing (fixes #1493)" until a new
snapshot is prepared.
2012-02-01 18:50:19 -08:00
Niko Matsakis
c36207bfb8 make boxes self-describing (fixes #1493) 2012-02-01 18:18:07 -08:00
Marijn Haverbeke
2dbaa05af8 Remove support for native types
Issue #1673
2012-02-01 12:23:13 +01:00
Tim Chevalier
e5d095d67e Change option::t to option
Now that core exports "option" as a synonym for option::t, search-and-
replace option::t with option.

The only place that still refers to option::t are the modules in libcore
that use option, because fixing this requires a new snapshot
(forthcoming).
2012-01-31 17:05:20 -08:00
Tim Chevalier
fba35e1a3c Require alts to be exhaustive
middle::check_alt does the work. Lots of changes to add default cases
into alts that were previously inexhaustive.
2012-01-31 10:08:24 -08:00
Brian Anderson
0e498da47e rustc: Allow attributes on methods. Closes #1709 2012-01-30 11:43:45 -08:00
Paul Woolcock
6ba3d24355 Remove ternary operator
`expr_ternary`, `ternary_to_if`, and all parses & lexer definitions have
been removed.
2012-01-30 18:21:19 +01:00
Paul Woolcock
e1251f7b00 Change all ternary ops to if/then/else
All the files below had at least one instance of the ternary operator
present in the source.  All have been changed to the equivalent
if/then/else expression.
2012-01-30 18:21:01 +01:00
Marijn Haverbeke
964bd485c6 Revert self types 2012-01-30 11:37:52 +01:00
Brian Anderson
3321880f13 Merge remote-tracking branch 'killerswan/fixing_strings_2'
Conflicts:
	src/comp/driver/driver.rs
	src/comp/middle/trans/base.rs
	src/comp/syntax/parse/lexer.rs
2012-01-27 16:44:40 -08:00
Marijn Haverbeke
b3f06c7d54 Stop passing spans to middle::trans functions that don't need them
Removes a bunch of (eventually) unused arguments. Makes span passing to debuginfo
explicit, instead of relying on the (usually incorrect) spans held in the contexts.

Closes #1439
2012-01-27 13:20:36 +01:00
Marijn Haverbeke
b80f0a3c9f Use the method name 'unary-' for overloading negation
It's less likely to clash with something than 'neg'.

Issue #1520
2012-01-27 10:06:53 +01:00
Brian Anderson
9f80a17c0e rustc: Add pprust::res_to_str 2012-01-26 20:54:36 -08:00
Marijn Haverbeke
c590bdeea4 Make re-exporting of impls work
Closes #1438
2012-01-26 18:58:35 +01:00
Marijn Haverbeke
6bead0e4cc Use operator names for operator methods
The methods used to implement operators now simply use
the name of the operator itself, except for unary -, which is called
min to not clash with binary -. Index is called [].

Closes #1520
2012-01-26 15:52:28 +01:00
Marijn Haverbeke
888262b337 Allow operator overloading of the indexing operator
The method `op_index` (which takes a single argument) is used for
this.

Issue #1520
2012-01-26 15:23:11 +01:00
Marijn Haverbeke
87b064b249 First stab at operator overloading
When no built-in interpretation is found for one of the operators
mentioned below, the typechecker will try to turn it into a method
call with the name written next to it. For binary operators, the
method will be called on the LHS with the RHS as only parameter.

Binary:

    +   op_add
    -   op_sub
    *   op_mul
    /   op_div
    %   op_rem
    &   op_and
    |   op_or
    ^   op_xor
    <<  op_shift_left
    >>  op_shift_right
    >>> op_ashift_right

Unary:

    -   op_neg
    !   op_not

Overloading of the indexing ([]) operator isn't finished yet.

Issue #1520
2012-01-26 14:25:06 +01:00
Marijn Haverbeke
1792d9ec96 Use string stored in codemap for pretty-printing comments and literals
Closes #1665
2012-01-26 10:52:08 +01:00
Marijn Haverbeke
ec4d05de3b Remove ty_native_fn
It was being used as a clumsy synonym of ty_fn.
2012-01-26 10:37:50 +01:00
Brian Anderson
b7b8455e54 rustc: Add pprust::variant_to_str 2012-01-25 17:22:08 -08:00
Brian Anderson
2999479a2d rustc: Allow attributes on enum variants. Closes #1663 2012-01-25 16:24:06 -08:00
Kevin Atkinson
60a146bf0f Correctly increment sess.byte_pos. 2012-01-25 16:01:58 -07:00
Kevin Atkinson
c5e03e0e59 Keep source file around after parsing.
Specifically box the string (to avoid unnecessary copies) and store it
in codemap::filemap.

Remove the hack in driver::diagnostic that rereads the source from the
file and instead just get the source from the filemap.

(This commit is also a prerequisite for issue #1612)
2012-01-25 16:00:47 -07:00
Marijn Haverbeke
2d4d8e8bdb Implement implicit self type parameters for ifaces
Closes #1661
2012-01-25 20:47:11 +01:00
Marijn Haverbeke
76aabbe99d Rename tag to enum throughout the compiler
This should reduce confusion of people trying to read the code.
2012-01-25 14:34:31 +01:00