-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parser changes for documentation generator #780
base: master
Are you sure you want to change the base?
Conversation
e87bd0e
to
73a73bf
Compare
85d6058
to
9c7b16f
Compare
@@ -403,7 +396,15 @@ class FastParser { | |||
|
|||
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{ |
There was a problem hiding this comment.
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.
This is used as input for the website generation frontend.
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.