Skip to content

Conversation

@fnussbaum
Copy link

@fnussbaum fnussbaum commented Mar 18, 2024

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 the PSpecification-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.

@fnussbaum fnussbaum force-pushed the viperdoc/parser-changes branch 2 times, most recently from e87bd0e to 73a73bf Compare March 25, 2024 07:19
@fnussbaum fnussbaum marked this pull request as ready for review March 25, 2024 07:31
@fnussbaum fnussbaum marked this pull request as draft March 25, 2024 09:00
@fnussbaum fnussbaum marked this pull request as ready for review March 25, 2024 12:29
@fnussbaum fnussbaum force-pushed the viperdoc/parser-changes branch from 85d6058 to 9c7b16f Compare March 25, 2024 16:13
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{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@fnussbaum fnussbaum marked this pull request as draft April 29, 2024 11:55
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

Successfully merging this pull request may close these issues.

2 participants