mirror of
https://github.com/GaloisInc/cryptol.git
synced 2024-12-01 08:32:23 +03:00
Fixup/changes to parsing comments
This addresses some issues where things like /**** were parsed as an operator, leading to parse errors with some comments. The intended behavior is as follows: 1. /* with no more stars starts a normal block comment 2. /**+ (i.e., 2 or more starts) starts a document comment 3. *+/ (i.e., any number of stars, follwed by /) ends any comment 4. /*+/ is a block coment (e.g., /*******/) is a block comment
This commit is contained in:
parent
8429d294e6
commit
74714f3071
@ -48,12 +48,13 @@ $unitick = \x7
|
||||
:-
|
||||
|
||||
<0,comment> {
|
||||
"/*" { startComment False }
|
||||
"/**" { startComment True }
|
||||
\/\* { startComment False }
|
||||
\/\*\*+ { startComment True }
|
||||
\/\*+\/ { startEndComment }
|
||||
}
|
||||
|
||||
<comment> {
|
||||
"*/" { endComent }
|
||||
\*+\/ { endComent }
|
||||
. { addToComment }
|
||||
\n { addToComment }
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ endComent cfg p txt s =
|
||||
case s of
|
||||
InComment d f [] cs -> (Just (mkToken d f cs), Normal)
|
||||
InComment d _ (q:qs) cs -> (Nothing, InComment d q qs (txt : cs))
|
||||
_ -> panic "[Lexer] endComment" ["outside commend"]
|
||||
_ -> panic "[Lexer] endComment" ["outside comment"]
|
||||
where
|
||||
mkToken isDoc f cs =
|
||||
let r = Range { from = f, to = moves p txt, source = cfgSource cfg }
|
||||
@ -81,6 +81,20 @@ addToComment _ _ txt s = (Nothing, InComment doc p stack (txt : chunks))
|
||||
InComment d q qs cs -> (d,q,qs,cs)
|
||||
_ -> panic "[Lexer] addToComment" ["outside comment"]
|
||||
|
||||
startEndComment :: Action
|
||||
startEndComment cfg p txt s =
|
||||
case s of
|
||||
Normal -> (Just tok, Normal)
|
||||
where tok = Located
|
||||
{ srcRange = Range { from = p
|
||||
, to = moves p txt
|
||||
, source = cfgSource cfg
|
||||
}
|
||||
, thing = Token (White BlockComment) txt
|
||||
}
|
||||
InComment d p1 ps cs -> (Nothing, InComment d p1 ps (txt : cs))
|
||||
_ -> panic "[Lexer] startEndComment" ["in string or char?"]
|
||||
|
||||
startString :: Action
|
||||
startString _ p txt _ = (Nothing,InString p txt)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user