On 22/12/2010 11:35 AM, Rafael Ávila de Espíndola wrote:
With the attached patch rustc can parse:

------------
use std;
use std();
use std(name = "foo");
use std(name = "foo", bar = "zed");

fn main() {
}

Great. Some comments on the patch:

 - in parse_meta_item, p.err("foobar") is no good; need a real error
   message. Or call unexpected(p, p.peek()).

 - parse_meta should use the parse_seq helper, rather than manually
   stepping through the commas.

 - It might be good to sink parse_use_and_imports down to the module
   level, as we at least support imports (possibly 'use' clasuses as
   well) within sub-modules. See below re: allowed locations.

I am setting up a github account and repo, but for now the patch is
attached

Ok. We'll need at least the mozilla foundation committer paperwork from you as well, unless you've been vetted for a mozilla project commit level yet. I'll file a bug if not.

Questions:

*) Are use and imports allowed anywhere in the file?

In the present grammar they're only accepted in a sort of "preamble" section before any actual items are declared in a module. This is not something everyone agrees with; some prefer to be able to toss imports and 'use' clauses anywhere they like. I don't really care at this point, trivial change.

I'm not sure if there'll be a big problem permitting imports in other block forms, but for now at least please limit it to module bodies, not any of the items within them.

*) How do I add a test that uses rustc?

The Makefile contains test-driver logic based on files it finds in test/*/*. So just drop a .rs or .rc file in one of the test subdirectories, and it'll start doing something (with parallel testing support via make -j as well):

  test/run-pass/  for tests you expect to run and exit ok

  test/run-fail/  for tests you expect to run and exit in failure

  test/compile-fail/  for tests you expect to fail compilation
                      (including an error-pattern comment in the file,
                       that tells the test driver logic what sort of
                       error to expect)

By default, the test driver logic runs all tests not listed in the Makefile as XFAIL'ed, so it'll run the rustboot one automatically. If you don't want to run the rustboot one, add the file name to TEST_XFAILS_X86.

Since we have so few tests runnning on rustc at the moment, we currently abuse the XFAIL concept and enumerate a list of the tests that *are* passing in TEST_XFAILS_SELF, wrapping the whole thing in a $(filter-out ...) call. So by default rustc will not run a test until you list it in TEST_XFAILS_SELF. At some point we'll invert this back and make it a proper XFAIL list.

*) Is there a syntax only mode? I had to add the main function to
prevent a crash.

No, but I wouldn't object to one. Part of the point of moving to a more functional form in rustc is to make the passes more independently testable. Feel free to add command-line processing to comp/driver/rustc.rs that supports partial pass-execution like that.

-Graydon
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to