https://github.com/zBaitu/rsyntax
rSyntax is cloned from Rust libsyntax. It's only used for rFmt, another Rust source code formatter.
Only 3 file are changed.
* lib.rs
Add some pub use.
* ast.rs
Add Debug for some struct/enum.
* parser.rs
Skip sub mod parse, and make the high position equals to the low position of the sub mod span, to specify this is a sub mod.
/// Parse a `mod <foo> { ... }` or `mod <foo>;` item
fn parse_item_mod(&mut self, outer_attrs: &[Attribute]) -> PResult<'a, ItemInfo> {
let id_span = self.span;
let id = self.parse_ident()?;
if self.check(&token::Semi) {
self.bump();
// baitu
// This mod is in an external file. Let's go get it!
// let (m, attrs) = self.eval_src_mod(id, outer_attrs, id_span)?;
// Ok((id, m, Some(attrs)))
Ok((id, ItemKind::Mod(
Mod {
inner: mk_sp(id_span.lo, id_span.lo),
items: Vec::new(),
}),
None))