forked from swiftlang/swift
-
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.
Parse and record top-level "items" rather than always forcing declara…
…tions. In the Swift grammar, the top-level of a source file is a mix of three different kinds of "items": declarations, statements, and expressions. However, the existing parser forces all of these into declarations at parse time, wrapping statements and expressions in TopLevelCodeDecls, so the primary API for getting the top-level entities in source files is based on getting declarations. Start generalizing the representation by storing ASTNode instances at the top level, rather than declaration pointers, updating many (but not all!) uses of this API. The walk over declarations is a (cached) filter to pick out all of the declarations. Existing parsed files are unaffected (the parser still creates top-level code declarations), but the new "macro expansion" source file kind skips creating top-level code declarations so we get the pure parse tree. Additionally, some generalized clients (like ASTScope lookup) will now look at the list of items, so they'll be able to walk into statements and expressions without the intervening TopLevelCodeDecl. Over time, I'd like to phase out `getTopLevelDecls()` entirely, relying on the new `getTopLevelItems()` for parsed content. We can introduce TopLevelCodeDecls more lazily for semantic walks.
- Loading branch information
1 parent
0cb2746
commit 0f9a706
Showing
16 changed files
with
159 additions
and
70 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
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
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
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
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.