~loic/decent-synquote-alternative

6d2f06d77cfd381fd4671fede6e1c4a51d47d8a9 — Loïc Lecrenier 2 years ago 77c9712
Add attribute fields to structs and enums
1 files changed, 14 insertions(+), 0 deletions(-)

M src/parser.rs
M src/parser.rs => src/parser.rs +14 -0
@@ 160,6 160,7 @@ impl Default for StructFieldIdentifier {

#[derive(Clone)]
pub struct Struct {
    pub attributes: Vec<TokenStream>,
    pub visibility: TokenStream,
    pub ident: Ident,
    pub generics: Generics,


@@ 197,6 198,7 @@ impl StructField {
}
#[derive(Clone)]
pub struct Enum {
    pub attributes: Vec<TokenStream>,
    pub visibility: TokenStream,
    pub ident: Ident,
    pub generics: Generics,


@@ 862,6 864,10 @@ impl TokenParser {
    }

    pub fn eat_struct(&mut self) -> Option<Struct> {
        let mut attributes = Vec::new();
        while let Some(attr) = self.eat_outer_attribute() {
            attributes.push(attr);
        }
        let visibility = self.eat_visibility();
        if let Some(_) = self.eat_ident("struct") {
            if let Some(ident) = self.eat_any_ident() {


@@ 873,6 879,7 @@ impl TokenParser {
                        let where_clause = self.eat_where_clause();
                        if let Some(_) = self.eat_punct(';') {
                            return Some(Struct {
                                attributes,
                                visibility,
                                ident,
                                generics,


@@ 890,6 897,7 @@ impl TokenParser {

                        if self.eat_eot() {
                            return Some(Struct {
                                attributes,
                                visibility,
                                ident,
                                generics,


@@ 900,6 908,7 @@ impl TokenParser {
                        }
                    } else {
                        return Some(Struct {
                            attributes,
                            visibility,
                            ident,
                            generics,


@@ 970,6 979,10 @@ impl TokenParser {
    }

    pub fn eat_enumeration(&mut self) -> Option<Enum> {
        let mut attributes = Vec::new();
        while let Some(attr) = self.eat_outer_attribute() {
            attributes.push(attr);
        }
        let visibility = self.eat_visibility();

        if let Some(_) = self.eat_ident("enum") {


@@ 987,6 1000,7 @@ impl TokenParser {
                    }
                    if self.eat_eot() {
                        return Some(Enum {
                            attributes,
                            visibility,
                            ident,
                            generics,