FWIW, I took a crack at making https://github.com/drrb/rust-netbeans work
better a few years ago, with limited results. In particular, their Antlr
grammar generates insanely deep trees that are not great for performance.

I have been working on something more performant, also based on an ANTLR
grammar, but using Antlr's lexer modes to handle things like macro_rules!
which is almost an embedded language, based off of the generic Antlr
language support I built here:
https://github.com/timboudreau/ANTLR4-Plugins-for-NetBeans (all of the
parser and lexer glue is generated for you from a few [big] annotations).

There are a few things I'm looking forward to trying:  Rust's borrow
checker is really just a reference-graph cycle checker with a few rules
about when cycles are allowed (things that implement the Copy trait, e.g.
primitives and things with #[derive Copy]);  the Antlr stuff lets you hang
arbitrary analyzers off a parse that collect patterns you describe in
source trees and store them in a couple of very tight int-array-based data
structures that are binary-searchable, so you can collect a tree of
variable references (yes, you *can* build a tree with a pair of int[]'s -
https://j.mp/31O7Ir6 ), build a graph (just some arrays of bit-sets where
intersection operations are cheap - this is how graphs should be modeled in
code, not as actual trees of objects) and the analysis is pretty simple.

This has been a spare-time kind of thing, but I could share it somewhere if
anyone is interested.

-Tim

Reply via email to