Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Cloogle
Cloogle
Commits
12840881
Verified
Commit
12840881
authored
May 18, 2018
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parse single-line docblocks (as in /** @type .. */)
parent
1ae8eaa9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
Clean/Doc.icl
Clean/Doc.icl
+2
-0
compiler-patch/scanner.patch
compiler-patch/scanner.patch
+14
-7
No files found.
Clean/Doc.icl
View file @
12840881
...
...
@@ -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
...
...
compiler-patch/scanner.patch
View file @
12840881
...
...
@@ -22,7 +22,7 @@
:: ScanContext
= GeneralContext
| TypeContext
@@ -493,12 +496,2
5
@@
@@ -493,12 +496,
3
2 @@
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 +76
2
,21 @@
@@ -746,6 +76
9
,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 +8
33
,24 @@
@@ -802,6 +8
40
,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 +16
15
,9 @@
@@ -1566,6 +16
22
,9 @@
toString ExistsToken = "E."
toString ForAllToken = "A."
...
...
@@ -111,7 +118,7 @@
toString token = "toString (Token) does not know this token"
instance == Token
@@ -1586,6 +16
38
,8 @@
@@ -1586,6 +16
45
,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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment