rsyntax

Crates.iorsyntax
lib.rsrsyntax
version1.10.0
sourcesrc
created_at2016-04-25 16:12:29.271038
updated_at2016-04-25 16:12:29.271038
descriptionA custom Rust parser cloned from Rust libsyntax. It is only used for rfmt, another Rust source code formatter.
homepagehttps://github.com/zBaitu/rsyntax
repositoryhttps://github.com/zBaitu/rsyntax
max_upload_size
id4857
size1,356,392
baitu (zBaitu)

documentation

README

rSyntax ---- Rust libsyntax for rFmt

https://github.com/zBaitu/rsyntax

Overview

rSyntax is cloned from Rust libsyntax. It's only used for rFmt, another Rust source code formatter.

Features

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))
Commit count: 14

cargo fmt