Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easier punctuation and keyword parsing #225

Closed
dtolnay opened this issue Nov 11, 2017 · 3 comments
Closed

Easier punctuation and keyword parsing #225

dtolnay opened this issue Nov 11, 2017 · 3 comments

Comments

@dtolnay
Copy link
Owner

dtolnay commented Nov 11, 2017

Currently parsing punctuation looks like syn!(ShlEq) and parsing a keyword looks like syn!(Default_). I would much rather write punct!(<<=) and keyword!(default) instead -- and have that produce the correct struct type without me having to look up its name.

@dtolnay
Copy link
Owner Author

dtolnay commented Nov 12, 2017

As part of this, let's also explore what it would look like to use type macros for token types, rather than giving them names like ShlEq and Default_. Type macros have been stable since 1.13.

ItemExternCrate {
    pub attrs: Vec<Attribute>,
    pub vis: Visibility,
    pub extern_token: Token![extern],
    pub crate_token: Token![crate],
    pub ident: Ident,
    pub rename: Option<(Token![as], Ident)>,
    pub semi_token: Token![;],
}

@dtolnay
Copy link
Owner Author

dtolnay commented Nov 12, 2017

Once the user is no longer typing the token names, will probably want to rename the various token structs to prefix the name, like ShlEq -> TokenShlEq like we do for items and exprs. This will avoid conflicts with prelude types like Default and syn types like Type (after we rename Ty -> Type).

@dtolnay
Copy link
Owner Author

dtolnay commented Nov 12, 2017

Implemented in #241.

@dtolnay dtolnay closed this as completed Nov 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant