@@ -396,14 +396,11 @@ class FastParser {
396396
397397 def stringLiteral [$ : P ]: P [PStringLiteral ] = P ((CharsWhile (_ != '\" ' ).! map PRawString .apply).pos.quotes map (PStringLiteral .apply _)).pos
398398
399- // TODO check positions
400399 def docAnnotation [$ : P ]: P [PAnnotation ] = P (" ///" ~~ CharsWhile (_ != '\n ' , 0 ).! ).map{
401- case s : String => p : ( FilePosition , FilePosition ) =>
400+ case s : String => p : Pos =>
402401 val annotationKey = PRawString (" doc" )(NoPosition , NoPosition )
403- val docstring = PStringLiteral (PGrouped .apply[PSym .Quote .type , PRawString ]
404- (PReserved .implied(PSym .Quote ), PRawString (s)(NoPosition , NoPosition ), PReserved .implied(PSym .Quote ))
405- (NoPosition , NoPosition ))(NoPosition , NoPosition )
406- val annotationValues = PDelimited .implied[PStringLiteral , PSym .Comma ](Seq (docstring), PReserved .implied(PSym .Comma ))
402+ val docstring = PStringLiteral (PGrouped [PSym .Quote .type , PRawString ](PReserved .implied(PSym .Quote ), PRawString (s)(p), PReserved .implied(PSym .Quote ))(p))(p)
403+ val annotationValues = PDelimited [PStringLiteral , PSym .Comma ](Some (docstring), Seq (), None )(p)
407404 PAnnotation (at = PReserved .implied(PSym .At ), key = annotationKey, values = PGrouped .impliedParen(annotationValues))(p)
408405 }.pos
409406
@@ -813,14 +810,12 @@ class FastParser {
813810 def whileStmt [$ : P ]: P [PKw .While => Pos => PWhile ] =
814811 P ((parenthesizedExp ~~ semiSeparated(annotatedInvariant) ~ stmtBlock()) map { case (cond, invs, body) => PWhile (_, cond, invs, body) })
815812
816- // TODO does this handle positions correctly/consistently?
817- // see also annotatedPrecondition, annotatedPostcondition
818813 def annotatedInvariant (implicit ctx : P [_]) : P [PSpecification [PKw .InvSpec ]] =
819- NoCut (P (annotation.rep(0 ) ~ invariant)).map{ case (anns, spec) => p : ( FilePosition , FilePosition ) =>
814+ NoCut (P (annotation.rep(0 ) ~ invariant)).map{ case (anns, spec) => p : Pos =>
820815 PSpecification [PKw .InvSpec ](spec.k, spec.e, anns)(p) }.pos
821816
822817 def invariant (implicit ctx : P [_]) : P [PSpecification [PKw .InvSpec ]] =
823- P ((P (PKw .Invariant ) ~ exp).map{ case (kw, e) => p : ( FilePosition , FilePosition ) =>
818+ P ((P (PKw .Invariant ) ~ exp).map{ case (kw, e) => p : Pos =>
824819 PSpecification [PKw .InvSpec ](kw, e)(p) }.pos | ParserExtension .invSpecification(ctx))
825820
826821 def localVars [$ : P ]: P [PKw .Var => Pos => PVars ] =
@@ -933,19 +928,19 @@ class FastParser {
933928 })
934929
935930 def annotatedPrecondition (implicit ctx : P [_]) : P [PSpecification [PKw .PreSpec ]] =
936- NoCut (P (annotation.rep(0 ) ~ precondition)).map{ case (anns, spec) => p : ( FilePosition , FilePosition ) =>
931+ NoCut (P (annotation.rep(0 ) ~ precondition)).map{ case (anns, spec) => p : Pos =>
937932 PSpecification [PKw .PreSpec ](spec.k, spec.e, anns)(p) }.pos
938933
939934 def precondition (implicit ctx : P [_]) : P [PSpecification [PKw .PreSpec ]] =
940935 P ((P (PKw .Requires ) ~ exp).map{ case (kw, e) => p : (FilePosition , FilePosition ) =>
941936 PSpecification [PKw .PreSpec ](kw, e)(p)}.pos | ParserExtension .preSpecification(ctx))
942937
943938 def annotatedPostcondition (implicit ctx : P [_]) : P [PSpecification [PKw .PostSpec ]] =
944- NoCut (P (annotation.rep(0 ) ~ postcondition)).map{ case (anns, spec) => p : ( FilePosition , FilePosition ) =>
939+ NoCut (P (annotation.rep(0 ) ~ postcondition)).map{ case (anns, spec) => p : Pos =>
945940 PSpecification [PKw .PostSpec ](spec.k, spec.e, anns)(p) }.pos
946941
947942 def postcondition (implicit ctx : P [_]) : P [PSpecification [PKw .PostSpec ]] =
948- P ((P (PKw .Ensures ) ~ exp).map{ case (kw, e) => p : ( FilePosition , FilePosition ) =>
943+ P ((P (PKw .Ensures ) ~ exp).map{ case (kw, e) => p : Pos =>
949944 PSpecification [PKw .PostSpec ](kw, e)(p)}.pos | ParserExtension .postSpecification(ctx))
950945
951946 def predicateDecl [$ : P ]: P [PKw .Predicate => PAnnotationsPosition => PPredicate ] = P (idndef ~ argList(formalArg) ~~~ bracedExp.lw.? ).map {
0 commit comments