rust-netbeans icon indicating copy to clipboard operation
rust-netbeans copied to clipboard

Consider replacing javacc with existing Antlr 4 grammar

Open timboudreau opened this issue 7 years ago • 8 comments

Antlr 4 is considerably more powerful than javacc, and javacc's future is a bit less certain these days; a Rust grammar is available that could probably just be picked up and used, but it would mean some rework.

More beneficially, it would allow for considerably more sophisticated syntax highlighting, such as distinguishing macro uses and more.

timboudreau avatar Sep 18 '18 18:09 timboudreau

Some work in progress on that

timboudreau avatar Oct 01 '18 17:10 timboudreau

Wow, great @timboudreau :) Nice to see someone works on the project.

Chris2011 avatar Oct 11 '18 09:10 Chris2011

@drrb what is your status atm moment? Do you still work on the project too?

Chris2011 avatar Oct 11 '18 09:10 Chris2011

I wanted to change the grammar to use the textmate rust file. @timboudreau can antlr and textmate coexist? I mean using the rust textmate for syntax highlighting and the antlr for everything else or doesn't make it sense? Maybe we can change to textmate and using the language server for the rest.

Chris2011 avatar Oct 08 '19 21:10 Chris2011

I kind of forked off from working on this to build a set of modules for supporting Antlr languages in NetBeans in general - i.e. define syntax highlighting and a few other things as an annotation that references the Antlr-generated lexer and parser, and the annotation processor generates 90% of the module including navigator panels and a bunch of other stuff - if you add some analysis stuff (also mostly annotations), you get things like finding references.

So, eventually I plan to get back to Rust+Antlr, building on that - I found one Antlr grammar that sort of worked but was kind of insanely written, and have been using that as the basis for a replacement.

timboudreau avatar Oct 09 '19 04:10 timboudreau

Hey @timboudreau what is the state of your rewrite process? I see that the last commit of you was also back in 2019. Maybe the grammar ist better nowadays? Just guessing. Found this just now: https://github.com/rrevenantt/antlr4rust

Chris2011 avatar Jan 06 '22 15:01 Chris2011

Funny, I just wrote a post about that a few minutes before seeing this on the netbeans-dev mailing list. I have a better Antlr grammar than that one in the works - lexer modes are really useful for handling some of the more painful corners such as macro_rules!. Will likely share it on Github in the next couple of weeks.

Digging into this project led me off on somewhat of a tangent into building generic Antlr language support (a few annotations to generate all of the antlr-to-netbeans parser and lexer glue code: https://github.com/timboudreau/ANTLR4-Plugins-for-NetBeans and only circled back to Rust support specifically around the time I needed to get a job, so it's been slow going since then).

timboudreau avatar Jan 10 '22 18:01 timboudreau

Great to hear :). Thx for your investigation.

Chris2011 avatar Jan 10 '22 18:01 Chris2011