Brian Anderson
35e9e02066
Use ioivec::read_whole_file_str in a few places
2011-08-02 10:39:14 -07:00
Brian Anderson
5f4b7e1ba7
Compiler accepts input from stdin when source file is called "-"
2011-08-02 10:39:09 -07:00
Marijn Haverbeke
985c32ef4c
Partially implement destructuring locals
...
You can now say
let {bcx, val} = some_result_returner();
Similar for loop variables. Assigning to such variables is not safe
yet. Function arguments also remain a TODO.
2011-08-01 17:51:37 +02:00
Marijn Haverbeke
48ec25da42
Get rid of walk.rs
...
And we're down to a single AST walker again
2011-07-31 12:24:14 +02:00
Graydon Hoare
0c9b749d20
Enable kind checking on typarams, fix kind constraints in library and comp.
2011-07-29 18:48:15 -07:00
Marijn Haverbeke
c34d74315f
Remove unreachable statements
2011-07-29 20:54:44 +02:00
Marijn Haverbeke
48cc11631c
Parse anonymous objs in statement position
...
Closes #761
2011-07-29 15:01:06 +02:00
Marijn Haverbeke
b1d2a00b4a
Remove support for obj dtors
2011-07-29 14:03:24 +02:00
Lindsey Kuper
b24da1c2e5
The names 'outer' and 'inner' make more sense than 'self' and 'with'.
...
(Also, some formatting and long-string cleanup.)
2011-07-28 14:54:32 -07:00
Graydon Hoare
3e63fdc4c9
Thread kinds into the type system. Don't quite activate yet, since it breaks stdlib and snapshot isn't ready to compile modified stdlib.
2011-07-28 13:29:39 -07:00
Paul Stansifer
86f337484e
Change macro syntax to accept a single expr, not a sequence of exprs.
2011-07-28 12:12:08 -07:00
Graydon Hoare
acac6abc85
Parse, store and print type parameter kind constraints.
2011-07-28 17:22:59 +00:00
Josh Matthews
f0e29c92aa
:: is allowed to start an expression. Close #762 .
2011-07-28 02:33:24 -04:00
Graydon Hoare
63f74f3771
Remove vestiges of "layers", insert skeletal do-nothing "kind" pass plus cached calculation of kind for each type.
2011-07-27 17:49:00 -07:00
Marijn Haverbeke
0186176ae9
Stop outputting spurious spaces in ivec types and empty mutable vecs
...
(in the pretty-printer)
2011-07-27 21:20:51 +02:00
Marijn Haverbeke
06e1d8b745
Remove superfluous spaces in pretty-printing of loops
...
(And extra parens around else-if tests)
2011-07-27 17:18:53 +02:00
Marijn Haverbeke
66b84e3f55
Make the pretty-printer output whitespace before obj drop clause
2011-07-27 16:54:48 +02:00
Marijn Haverbeke
0334faef1f
Improve pretty-printing of constraints
...
(Methods still don't seem to have constraints associated with them.
Method types do, so I guess this is a TODO.)
2011-07-27 16:50:51 +02:00
Marijn Haverbeke
19394a50e7
Make printing of comments inside bindings slightly less broken
2011-07-27 16:24:41 +02:00
Marijn Haverbeke
e3552da0e6
No longer allow 'case' keyword before patterns
2011-07-27 16:01:31 +02:00
Marijn Haverbeke
6e2a7bff7f
Fix damage done by the pretty-printer
2011-07-27 15:54:33 +02:00
Marijn Haverbeke
df7f21db09
Reformat for new syntax
2011-07-27 15:54:33 +02:00
Marijn Haverbeke
66c1ca857b
Update the parser to accept the new syntax
2011-07-27 15:19:31 +02:00
Marijn Haverbeke
300eb30113
Output native_name field for native mods when needed
2011-07-27 15:19:31 +02:00
Marijn Haverbeke
e9b2487db7
Have the pretty-printer parentesize unary ops when needed
2011-07-27 15:19:31 +02:00
Marijn Haverbeke
a6260ebaa2
Update the pretty-printer to output the new syntax
2011-07-27 15:19:31 +02:00
Marijn Haverbeke
557c2a380a
Parenthesize ivec types as needed
2011-07-27 15:19:31 +02:00
Graydon Hoare
797cd9fd0e
Try to keep the local and its type together when wrapping a long decl.
2011-07-26 16:28:16 -07:00
Graydon Hoare
4070b75914
Prohibit breaking between "let" and "=" in local decls.
2011-07-26 15:58:50 -07:00
Graydon Hoare
821c1e7a44
Trailing whitespace.
2011-07-26 15:41:43 -07:00
Graydon Hoare
ba626779de
Handle printing 'auto' occurring in loop-variable context.
2011-07-26 15:41:42 -07:00
Graydon Hoare
1c97510a16
Improve printing of mod and native mod.
2011-07-26 15:41:42 -07:00
Graydon Hoare
69f8d0e787
Handle hardbreaks at bol slightly better, including break_offset calls (tuck offset into previous hardbreak).
2011-07-26 15:41:42 -07:00
Graydon Hoare
0a69196ef3
Handle column-zero \n explicitly rather than looking for \n\n.
2011-07-26 15:41:42 -07:00
Graydon Hoare
63aa869405
Consume EOL after line comment.
2011-07-26 15:41:42 -07:00
Michael Sullivan
8c8fa79312
Add block and closure protos and parse/pp block and lambda exprs.
2011-07-26 12:30:14 -07:00
Paul Stansifer
bca34d11ef
Oops, left whitespace.
2011-07-26 11:11:25 -07:00
Paul Stansifer
d11c887382
Add basic support for blocks and types in macros.
2011-07-26 11:09:37 -07:00
Marijn Haverbeke
473a03a214
Add 'simple' visiting to visit.rs
2011-07-26 16:35:31 +02:00
Marijn Haverbeke
2509a3dcae
Resolve loop collection expressions in the right scope
...
Closes #745
2011-07-26 15:52:59 +02:00
Marijn Haverbeke
2c1250780d
Remove tuple support from the compiler
2011-07-26 15:19:56 +02:00
Marijn Haverbeke
c0976ad70b
Properly parse 'auto' for loop variable types
2011-07-26 14:53:01 +02:00
Marijn Haverbeke
aea537779e
Remove all uses of tuples from the compiler and stdlib
2011-07-26 14:06:02 +02:00
Marijn Haverbeke
e123366bff
Make the pretty-printer output new-style syntax for records
2011-07-26 10:53:24 +02:00
Marijn Haverbeke
ce808bbc6f
Make the pretty-printer output new-style syntax for local decls
2011-07-26 10:40:28 +02:00
Marijn Haverbeke
252b8ffe42
Add support for new-style local decls
...
let x = 5;
let y: int = 10;
// as soon as a typestate bug is fixed:
let x: str = foo, y <- 20u;
'auto' and 'type-first let' will soon be dropped.
2011-07-26 10:27:26 +02:00
Graydon Hoare
5ab213a464
Correct input coordinate tracking on block-opening brace.
2011-07-25 17:35:40 -07:00
Graydon Hoare
1243ce271e
Recognize and preserve first blank line if first line of file.
2011-07-25 17:10:08 -07:00
Michael Sullivan
25a89e068d
Rename the block type to be blk also. Sorry.
2011-07-25 14:18:07 -07:00
Graydon Hoare
552bff8a21
Adjust pp interface to that printing a crate (an reproducing literals/comments) takes a reader, not just a filename. Fixes first big pp-fuzzer bug.
2011-07-25 14:04:49 -07:00
Michael Sullivan
6bcdb48e35
Disallow block as a variable name in preparation for it becoming a keyword.
2011-07-25 13:42:38 -07:00
Marijn Haverbeke
19507787a9
Add support for bracey record types and literals
...
type foo = {mutable x: int, y: int};
auto myfoo = {mutable x: 10, y: 20u};
The old syntax is also still supported.
2011-07-25 17:41:00 +02:00
Marijn Haverbeke
cce1b4667b
Add look-ahead to parser object
2011-07-25 17:16:41 +02:00
Marijn Haverbeke
dca67f95cb
Make the lexer slightly less stateful
2011-07-25 16:46:08 +02:00
Marijn Haverbeke
e949aab10a
Remove some rustboot-isms
...
Closes #464
2011-07-25 15:07:48 +02:00
Marijn Haverbeke
f0be65cb50
Fix span information returned by parser::parse_seq
...
Its hi pos used to be the end of the token after the sequence. It now
properly reports the end of the closing token.
2011-07-25 14:04:37 +02:00
Michael Sullivan
f2f8943a85
Add a "fake" def_upvar and mechanisms to create it.
2011-07-22 17:46:52 -07:00
Paul Stansifer
e18d70fe12
Implement Macro By Example.
2011-07-22 16:53:43 -07:00
Marijn Haverbeke
b9b674abe7
Start adding support for multiple variable declarations per stmt
...
This adds parser support and most of the machinery for
auto x = 10, y = 20;
However, the above still goes wrong somewhere in typestate, causing
the state checker to believe only the last variable in the list is
initialized after the statement.
Tim, if you have a moment, could you go over the changes to the tstate
code in this patch and see where I'm going wrong?
Multi-var-decls without the typestate extension
Add a loop
2011-07-22 17:51:26 +02:00
Lindsey Kuper
8ebd292253
Consolidate obj_field_from_anon_obj_field().
2011-07-21 15:12:27 -07:00
Lindsey Kuper
55acc737a8
Remove vestiges of typarams from anon objs.
2011-07-21 15:12:27 -07:00
Marijn Haverbeke
c32f525f73
Make the pretty-printer output paren-free and case-free code
...
We should probably do another pretty-printing pass soon.
2011-07-21 15:37:14 +02:00
Tim Chevalier
8a7f2e0fe5
Parse nil literals (including in patterns)
...
Closes #622 .
2011-07-20 16:02:53 -07:00
Tim Chevalier
bd4aeef78b
Beginnings of support for constrained types
...
Programs with constrained types now parse and typecheck, but
typestate doesn't check them specially, so the one relevant test
case so far is XFAILed.
Also rewrote all of the constraint-related data structures in the
process (again), for some reason. I got rid of a superfluous
data structure in the context that was mapping front-end constraints
to resolved constraints, instead handling constraints in the same
way in which everything else gets resolved.
2011-07-19 18:57:28 -07:00
Michael Sullivan
da2a7e5bd2
Simple refactoring in the pretty printer.
...
Introduce a proto_to_str function to find the string representation of a given
proto instead of casing on the proto in multiple places.
2011-07-19 18:30:08 -07:00
Brian Anderson
c40d6265ce
Support x86 stdcall convention
...
This allows rust to call the Win32 API
2011-07-18 13:56:15 -07:00
Josh Matthews
a411c865b2
Make clear the differentiation between char pos and byte pos in filemaps. Fix up error printing for files with multi-byte characters.
2011-07-16 15:57:24 -07:00
Josh Matthews
3ce43f37d2
Fix pre-existing problem with filemap line positions always starting at 0. Fix error line output to only retrieve up to the nearest newline.
2011-07-16 15:56:31 -07:00
Josh Matthews
a5ac8f16db
Use the actual start position of the file in the codemap rather than the position of the first newline.
2011-07-16 15:56:31 -07:00
Josh Matthews
63598248e4
Reenable error line printing.
2011-07-16 15:56:31 -07:00
Josh Matthews
df74f2cde9
Fix error line display slicing.
2011-07-16 15:56:28 -07:00
Patrick Walton
917afa4cc9
rustc: Remove a bunch of exterior vectors
2011-07-15 11:38:46 -07:00
Patrick Walton
be489ee9e2
rustc: Move much of metadata reading over to interior vectors
2011-07-14 12:00:48 -07:00
Graydon Hoare
39151f2ad8
Prohibit trailing whitespace under 'tidy' script. Clean up all caught cases.
2011-07-13 15:44:09 -07:00
Tim Chevalier
5e1a6dac44
Parse nullary ret correctly
...
ret is similar to fail: if not followed by an expression, it
should be parsed as a ret without an argument. The old version would
fail if ret was followed by a close paren (for example). Fixed it.
Closes #676 .
2011-07-13 15:00:59 -07:00
Tim Chevalier
0c913e63d9
Add some missing cases to token::can_begin_expr
2011-07-13 15:00:23 -07:00
Marijn Haverbeke
6cb5c0980a
box patterns, expect for the trans part
2011-07-13 10:50:16 +02:00
Graydon Hoare
e53cfb979b
Fix fast-check target by disabling code snippet printing on warnings (broken on .rc files) and adding an xfail-fast flag for global-scope.rs.
2011-07-12 17:36:57 -07:00
Brian Anderson
73e6a4f9e5
Elide existing main function when building a test runner. Issue #428
...
This prevents any defined main function from colliding with the one
synthesized for the test runner. This is not the best solution since it
doesn't compile a function the user defined, but I don't think it's likely to
be a problem in the near term.
2011-07-12 16:54:46 -07:00
Patrick Walton
a3add84909
rustc: Remove some interior vectors from typestate and some useless vec-related imports
2011-07-12 16:44:57 -07:00
Patrick Walton
e038e8e52b
rustc: Move ppaux away from exterior vectors
2011-07-12 16:35:02 -07:00
Patrick Walton
60cffd7116
rustc: Complete the transition of pprust to interior vectors
2011-07-12 16:13:30 -07:00
Marijn Haverbeke
bde52808f0
Update pretty-printing of '...' in record patterns to be ', _' instead
2011-07-12 17:58:40 +02:00
Brian Anderson
a5ec51d6a1
Fix pretty-printing of literals again. Issue #672
...
The pos variable is one character beyond where I thought it was.
2011-07-11 21:31:14 -07:00
Tim Chevalier
a8b1ea159c
Make the parser add correct spans to view_items
...
Closes #650 .
2011-07-11 19:12:02 -07:00
Paul Stansifer
2e46438507
So... I can't spell 'ellipsis'.
2011-07-11 18:52:50 -07:00
Paul Stansifer
9a0e85a920
Change "etc" syntax for record patterns from {a:b ...}
to {a:b, _}
.
2011-07-11 18:52:50 -07:00
Paul Stansifer
48dbee6b47
Add elipses, reorganize the macro components into their own AST node.
2011-07-11 18:52:50 -07:00
Paul Stansifer
425732311a
Move macro expansion to a separate phase, change macro syntax, and add parse_sess to session.
2011-07-11 18:52:50 -07:00
Paul Stansifer
80cf4ecd3b
Add nodes for embedding types and blocks in expressions for macros.
2011-07-11 18:52:10 -07:00
Josh Matthews
fd24fd5e31
Only print up to six lines on error. Print ^~~~~ to highlight error span.
2011-07-11 18:44:27 -07:00
Josh Matthews
b62fcdcc36
Hack to print lines when error spans are available.
2011-07-11 18:44:27 -07:00
Tim Chevalier
1870e97559
Visit the type argument in a port expression
...
This closes #664 .
2011-07-11 18:12:00 -07:00
Brian Anderson
e45819ad70
Add parser::parse_crate_from_source_str
...
The fuzzer wants to be able to do stuff like this
2011-07-11 17:46:24 -07:00
Brian Anderson
9fe03b3c55
Pull lexer creation out of new_parser
...
This will allow custom lexers to be injected into the parser (for fuzzing)
2011-07-11 16:56:02 -07:00
Brian Anderson
08f8753d80
Pull file reading out of the lexer
2011-07-11 16:56:02 -07:00
Patrick Walton
05390b4b38
rustc: Implement explicit global scope resolution via leading "::"; add a test case
2011-07-11 16:02:16 -07:00
Brian Anderson
7fc7ebd520
The lexer's get_mark_str should slice by byte position, not char. Closes #654
2011-07-11 14:41:55 -07:00
Marijn Haverbeke
55e348280e
Fix pretty-printing of record patterns
2011-07-11 21:23:49 +02:00
Marijn Haverbeke
7595fe5153
Implement record patterns
...
Closes #469 .
2011-07-11 15:32:41 +02:00
Marijn Haverbeke
12cb128a0a
Move visit to newtype-style nominal type
...
This makes getting the function fields out of the visitor less
cumbersome and more efficient (no take/drop).
2011-07-11 13:53:50 +02:00
Marijn Haverbeke
86ee3454a1
Implement or-patterns in case clauses
...
You can now say
expr_move(?dst, ?src) | expr_assign(?dst, ?src) { ... }
to match both expr_move and expr_assign. The names, types, and number
of bound names have to match in all the patterns.
Closes #449 .
2011-07-11 11:01:54 +02:00
Jesse Ruderman
ea69f48eac
Add a missing case so nbody.rs can pp
2011-07-10 17:05:25 -07:00
Jesse Ruderman
ab50da9445
Export noop_fold_expr so the fuzzer can use it
2011-07-10 17:05:25 -07:00
Brian Anderson
6d3513eaee
Make #fmt work from inside std. Issue #175
...
At long last, this patch makes #fmt usable from inside the standard library.
The way it does it us very hackish, but at least it works now.
2011-07-10 17:00:28 -07:00
Brian Anderson
5543404abe
Track the path as we fold over the AST looking for unit tests. Issue #428
2011-07-09 12:35:30 -07:00
Tim Chevalier
7060f4c89c
Alias-ify some prettyprinting functions
2011-07-08 22:25:57 -07:00
Lindsey Kuper
33ce1164e2
Nicer pretty-printing for anon objs. Closes #499 .
...
(Incidentally, what's the right way to test changes to the
pretty-printer? There has to be a better way than what I did, which
was to log_err the results of expr_to_str as exprs passed through
trans and glance at the output.)
2011-07-08 15:00:47 -07:00
Patrick Walton
e1b107d74e
rustc: Remove all exterior vectors from the AST
2011-07-07 18:39:05 -07:00
Patrick Walton
0e2fff5337
rustc: Change lots of AST nodes to use interior vectors
2011-07-07 12:53:17 -07:00
Patrick Walton
2f29f9931d
rustc: Make constraint args in the AST interior vectors
2011-07-06 16:19:19 -07:00
Patrick Walton
f164d7779a
rustc: Move AST constraints to interior vectors
2011-07-06 16:12:39 -07:00
Patrick Walton
c83782f500
rustc: Migrate core AST types to interior vectors
2011-07-06 16:01:47 -07:00
Patrick Walton
aad0bcc8d5
rustc: Make AST tuple types use interior vectors
2011-07-06 15:53:47 -07:00
Patrick Walton
401b6362d7
rustc: Make meta items into interior vectors
2011-07-06 15:46:03 -07:00
Patrick Walton
479ce4d783
rustc: Move crate directives over to interior vectors
2011-07-06 15:15:06 -07:00
Patrick Walton
0226f56115
rustc: Convert attribute in the AST to interior vectors
2011-07-06 15:15:00 -07:00
Patrick Walton
7714cb297b
rustc: Make AST paths use interior vectors
2011-07-06 15:14:52 -07:00
Brian Anderson
b06ccb45ab
Begin adding unit testing infrastructure to the compiler
...
Add a --test flag and a pass for transforming the AST to generate a test
harness.
Issue #428
2011-07-06 14:39:36 -07:00
Patrick Walton
e066bae56e
rustc: Move the interner over to interior vectors
2011-07-06 12:05:13 -07:00
Patrick Walton
717ac3df77
rustc: Make the various constraint-related types in middle::ty use interior vectors
2011-07-06 12:05:06 -07:00
Lindsey Kuper
e30d2c82ae
Simplify AST for expr_anon_obj.
2011-07-06 11:36:06 -07:00
Patrick Walton
bbdba21b1f
rustc: Revert the conversion to interior vectors due to heap corruption
2011-07-06 11:26:26 -07:00
Patrick Walton
ec890fff23
Temp commit on the way to making meta_item into an interior vector
2011-07-06 11:09:08 -07:00
Patrick Walton
3f6c9f8d84
rustc: Move crate directives over to interior vectors
2011-07-06 11:09:08 -07:00
Patrick Walton
c927d97fa0
rustc: Convert attribute in the AST to interior vectors
2011-07-06 11:09:08 -07:00
Patrick Walton
1591955adf
rustc: Make AST paths use interior vectors
2011-07-06 11:09:08 -07:00
Patrick Walton
bd7a072266
rustc: Move the interner over to interior vectors
2011-07-06 11:09:06 -07:00
Patrick Walton
b9a2117475
rustc: Make the various constraint-related types in middle::ty use interior vectors
2011-07-06 11:09:06 -07:00
Marijn Haverbeke
8e585e7008
Support paren-free and lightweight-case syntax
...
(The old syntax is still supported as well, for now.)
It is now possible to leave out the parens around if, while, and
do/while conditions, and around alt expressions. Cases in an alt block
can now leave off the case keyword and parens around the pattern.
After the next snapshot, we can start migrating our code to use the
new alt syntax, probably with a pretty-printer pass. The paren-free
syntax will remain optional (you may always parenthesize expressions),
but the old case syntax will no longer be supported in the future.
2011-07-06 17:50:52 +02:00
Marijn Haverbeke
7661c08496
Remove temporary stdlib placeholders, use actual stdlib functions
...
(Possible now that a snapshot took place.)
2011-07-06 16:46:17 +02:00
Brian Anderson
2cb129355b
Change ast::meta_name_value to accept any literal, not just string
...
This isn't useful for much of anything yet, since metadata::encoder doesn't
know how to handle the non-string variants.
Issue #611
2011-07-05 17:25:18 -07:00
Graydon Hoare
741db24e49
Print remaining comments at end of *crate*, not module.
2011-07-05 14:44:54 -07:00
Brian Anderson
57d94493cf
Remove unused eval function. Issue #604
2011-07-05 13:34:02 -07:00
Brian Anderson
8499c77cee
Parse attributes for native items. Closes #609
2011-07-05 12:43:44 -07:00
Marijn Haverbeke
6fd6fdea93
Move everything syntax-related to syntax/, break deps on rest of compiler
...
src/comp/syntax is currently just a sub-module of rustc, but it will,
in the near future, be its own crate. This includes:
- The AST data structure
- The parser
- The pretty-printer
- Visit, walk, and fold
- The syntax extension system
- Some utility stuff that should be in the stdlib*
*) Stdlib extensions currently require a snapshot before they can be
used, and the win build is very broken right now. This is temporary
and will be cleaned up when one of those problems goes away.
A lot of code was moved by this patch, mostly towards a more organized
layout. Some package paths did get longer, and I guess the new layout
will take some getting used to. Sorry about that!
Please try not to re-introduce any dependencies in syntax/ on any of
the other src/comp/ subdirs.
2011-07-05 15:57:21 +02:00