-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ast: Misc. refactoring on annotations support
This commit combines a bunch of refactoring on annotations to support future work. Specifically: * Annotations are now normal AST nodes/statements. This means that annotations store locations and also implement String() and Compare(). Annotations are now correctly compared during module comparison and annotations are included in the module string representation (before annotations would be dropped when the module String() function was called.) Also, the visitor and transformer functions support annotations now. * Annotations are no longer hidden behind an interface. Instead, there is a single annotation struct that we can evolve over time. It was unclear how the Annotations interface was going to work in the long-term (e.g., callers would not be able to define their own annotation types since the parser needs to be aware of them.) With this change, Annotations are just structs now. We can extend the struct as needed going forward. Custom data can be stored in a dedicated field. * Annotation parsing has been refactored. We now attach annotations to the statement following the annotation. The parser will reject METADATA blocks that contain whitespace between the METADATA hint and the YAML block. Similarly, we no longer support trailing unindented comments that follow the METADATA block. Users can inject whitespace after the YAML block if they want to include trailing comments. * The opa parse subcommand now enables annotation processing. Signed-off-by: Torin Sandall <[email protected]>
- Loading branch information
Showing
15 changed files
with
869 additions
and
338 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
Oops, something went wrong.