Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust definition is a bit out of date #2937

Closed
icorderi opened this issue Nov 22, 2014 · 6 comments
Closed

Rust definition is a bit out of date #2937

icorderi opened this issue Nov 22, 2014 · 6 comments

Comments

@icorderi
Copy link

There are a few things that causes the the code to get all wonky with CodeMirror and some new stuff missing.
The following are some things I've found so far:

// Nested generic types break the highlighting inside the function block
fn foo(&self, bar: str) -> S<T<Q>> {
    let x = 2; 
    let y = some.func(&bar);
}
// the grammar is not liking the () around proc
spawn(proc() {
      let x = 12; // the code inside proc is not parsed correctly and breaks the rest
});
let mut x = 2; // it doesn't know mut is a keyword not pat of the name
fn drop(&mut self) { // &mut is a keyword too
}
match x { // match is not being treated as a keyword
}
pub fn foo()  {} // access modifiers are absent from the grammar
#[unstable] // we might want to treat this #[] as a special thing
pub fn foo() -> (){ }
// 'static is a keyword too
 pub fn foo() -> &'static T {
 }
// not sure why, but this reads better in github.
// They all get ignored until the last call before the (), 
// it's very easy to identify what you are calling without getting lost 
 some.func.call(&bar); 
// this is another case where it reads more clear in Github, 
// with the current CodeMirror it all comes out in the same color
Ok(foo.bar);
Err(foo.bar.call());
// I would place mut, &, &mut, ref and * (deref) 
// on their own little group

I noticed @marijnh did the initial contribution and maintained it over the years.
Can you help update the language definition?

@marijnh
Copy link
Member

marijnh commented Nov 22, 2014

This is a known problem. The Rust mode was written back when Rust was quite a different language. I looked into updating it recently, but Rust still does not have a formal grammar, so I gave up on that. It'll have to be rewritten from scratch, I think, since the current approach is used to work around some strangeness in the old syntax that no longer exists.

@icorderi
Copy link
Author

Is true, I haven't been able to find all the grammar on a singe place but there is a lot of info on the Rust grammar definition throughout this document.
I'll be more than happy to help out map that into CodeMirror.

@marijnh
Copy link
Member

marijnh commented Nov 22, 2014

That document is where I started, but the pseudo-formal grammar parts are a joke -- they are full of holes, refer to other productions that are never defined, etc. Then I looked at the parser, but that is, if I remember correctly, over 4000 lines long, so I just gave up. If someone who is familiar with modern Rust wants to take a stab at this, that'd be great.

@icorderi
Copy link
Author

I'll ask around tomorrow at the IRC channel.

@icorderi
Copy link
Author

@marijnh I left an issue at Rust's repo, hopefully we get some feedback and volunteers for this.

@marijnh
Copy link
Member

marijnh commented Sep 2, 2015

This was fixed by the new Rust mode.

@marijnh marijnh closed this as completed Sep 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants