forked from dtolnay/syn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite the AST to be a bit more user-friendly
This commit is a relatively large rewrite of the AST that `syn` exposes. The main change is to expose enums-of-structs rather than enums-with-huge-tuple-variants. The best example of this is `ItemKind::Fn` which changed from: enum ItemKind { Fn(Box<FnDecl>, Unsafety, Constness, Option<Abi>, Generics, Box<Block>), ... } to enum ItemKind { Fn(ItemFn), ... } struct ItemFn { decl: Box<FnDecl>, unsafety: Unsafety, constness: Constness, abi: Option<Abi>, generics: Generics, block: Box<Block>, } This change serves a few purposes: * It's now much easier to add fields to each variant of the ast, ast struct fields tend to be "by default ignored" in most contexts. * It's much easier to document what each field is, as each field can have dedicated documentation. * There's now canonicalized names for each field (the name of the field) which can help match `match` statements more consistent across a codebase. A downside of this representation is that it can be a little more verbose to work with in `match` statements and during constructions. Overall though I'd feel at least that the readability improved significantly despite the extra words required to do various operations. Closes dtolnay#136
- Loading branch information
1 parent
56c5570
commit 62a0a59
Showing
22 changed files
with
3,398 additions
and
2,391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.