Verified Commit 12840881 authored by Camil Staps's avatar Camil Staps 🙂

Parse single-line docblocks (as in /** @type .. */)

parent 1ae8eaa9
......@@ -198,6 +198,7 @@ where
parsef :: [[Char]] -> Either ParseError (DocBlock, [ParseWarning])
parsef [] = Right ([], [])
parsef lines = case span (\l -> isEmpty l || hd l <> '@') lines of
([], [ln]) = parseFields [ln]
([], rest) = appSnd (\ws -> [NoDescription:ws]) <$> parseFields rest
(desc, rest) = appFst (\d -> [("description", linesToString desc):d]) <$> parseFields rest
......@@ -219,6 +220,7 @@ prepareString :: (String -> Either ParseError [[Char]])
prepareString = checkAsterisks o map trim o break '\n' o fromString
where
checkAsterisks :: [[Char]] -> Either ParseError [[Char]]
checkAsterisks lines=:[_] = Right lines
checkAsterisks lines
| all (\l -> isEmpty l || hd l == '*') lines
= Right $ map (safetl o dropWhile ((==) '*')) lines
......
......@@ -22,7 +22,7 @@
:: ScanContext
= GeneralContext
| TypeContext
@@ -493,12 +496,25 @@
@@ -493,12 +496,32 @@
TryScanComment c1=:'/' input
# (eof,c2, input) = ReadNormalChar input
| eof = (No, c1, input)
......@@ -43,9 +43,16 @@
+ | eof = (No, c1, input)
+ | c3 == '*' // Docblock?
+ # (eof,c4,input) = ReadNormalChar input
+ | eof = (No, c1, charBack (charBack input)) // Docblock, starts with /**<space>
+ | eof = (No, c1, charBack (charBack input)) // Docblock, starts with /**<eof>
+ | c4 == '/' = SkipWhites input // Skip over /**/
+ = case ScanComment input of // Normal comment, starts with /**<no-space>
+ | c4 == ' '
+ # (eof,c5,input) = ReadNormalChar input
+ | eof = (No, c1, charBack (charBack (charBack input))) // Docblock, /** <eof>
+ | c5 == '@' = (No, c1, charBack (charBack (charBack (charBack input)))) // Single-line docblock, /** @
+ = case ScanComment input of
+ (No,input) -> SkipWhites input
+ (er,input) -> (er, c5, input)
+ = case ScanComment input of // Normal comment
+ (No,input) -> SkipWhites input
+ (er,input) -> (er, c4, input)
+ = case ScanComment input of
......@@ -54,7 +61,7 @@
TryScanComment c input
= (No, c, input)
@@ -746,6 +762,21 @@
@@ -746,6 +769,21 @@
| eof = (IdentToken "A", input)
| c1 == '.' = (ForAllToken, input)
= ScanIdentFast 1 (charBack input) TypeContext
......@@ -76,7 +83,7 @@
Scan c input co
| IsDigit c = ScanNumeral 0 input [c]
| IsIdentChar c co
@@ -802,6 +833,24 @@
@@ -802,6 +840,24 @@
| isSpecialChar c = ScanOperator (n + 1) input [c:token] co
= CheckReservedOperator (revCharListToString n token) (charBack input)
......@@ -101,7 +108,7 @@
CheckReservedIdent :: !ScanContext !String !Input -> (!Token, !Input)
CheckReservedIdent GeneralContext s i = CheckGeneralContext s i
CheckReservedIdent TypeContext s i = CheckTypeContext s i
@@ -1566,6 +1615,9 @@
@@ -1566,6 +1622,9 @@
toString ExistsToken = "E."
toString ForAllToken = "A."
......@@ -111,7 +118,7 @@
toString token = "toString (Token) does not know this token"
instance == Token
@@ -1586,6 +1638,8 @@
@@ -1586,6 +1645,8 @@
equal_args_of_tokens (ErrorToken id1) (ErrorToken id2) = id1 == id2
equal_args_of_tokens (QualifiedIdentToken module_name1 ident_name1) (QualifiedIdentToken module_name2 ident_name2)
= ident_name1==ident_name2 && module_name1==module_name2
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment