Parser changes for documentation generator#780
Draft
fnussbaum wants to merge 14 commits intoviperproject:masterfrom
Draft
Parser changes for documentation generator#780fnussbaum wants to merge 14 commits intoviperproject:masterfrom
fnussbaum wants to merge 14 commits intoviperproject:masterfrom
Conversation
e87bd0e to
73a73bf
Compare
85d6058 to
9c7b16f
Compare
JonasAlaif
reviewed
Mar 25, 2024
| def stringLiteral[$: P]: P[PStringLiteral] = P((CharsWhile(_ != '\"').! map PRawString.apply).pos.quotes map (PStringLiteral.apply _)).pos | ||
|
|
||
| def annotation[$: P]: P[PAnnotation] = P((P(PSym.At) ~~ annotationIdentifier ~ argList(stringLiteral)) map (PAnnotation.apply _).tupled).pos | ||
| def docAnnotation[$: P]: P[PAnnotation] = P("///" ~~ CharsWhile(_ != '\n', 0).!).map{ |
Contributor
There was a problem hiding this comment.
The /// should be parsed with e.g. P(PSym.TripleSlash), the position of the CharsWhile(_ != '\n', 0).! should actually be precise when saving it to a PRawString - desugaring during parsing is the wrong place to do it. I would create a sealed PAnnotation trait with all the methods that the current PAnnotation has and have two classes implementing it.
This is used as input for the website generation frontend.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces changes to the parser for the documentation generator in development:
Comments starting with exactly three slashes are parsed as annotations with the key "doc". Moreover, annotations can now be put before specification keywords. Such annotations are put into a new
annotations-field in thePSpecification-nodes in the parse AST.During translation into the Viper AST, specification annotations are pushed into the corresponding expression, as there are no specification nodes in the AST.