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

Comments

Projects
None yet
2 participants
@icorderi

icorderi commented Nov 22, 2014

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

This comment has been minimized.

Show comment
Hide comment
@marijnh

marijnh Nov 22, 2014

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@icorderi

icorderi Nov 22, 2014

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.

icorderi commented Nov 22, 2014

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

This comment has been minimized.

Show comment
Hide comment
@marijnh

marijnh Nov 22, 2014

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@icorderi

icorderi Nov 23, 2014

I'll ask around tomorrow at the IRC channel.

icorderi commented Nov 23, 2014

I'll ask around tomorrow at the IRC channel.

@icorderi

This comment has been minimized.

Show comment
Hide comment
@icorderi

icorderi Nov 24, 2014

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

icorderi commented Nov 24, 2014

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

@marijnh

This comment has been minimized.

Show comment
Hide comment
@marijnh

marijnh Sep 2, 2015

Member

This was fixed by the new Rust mode.

Member

marijnh commented Sep 2, 2015

This was fixed by the new Rust mode.

@marijnh marijnh closed this Sep 2, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment