Skip to content
Snippets Groups Projects
Commit 0c305dca authored by sof's avatar sof
Browse files

[project @ 1997-03-19 09:09:33 by sof]

Fixed to gracefully handle decl delims (;;) inside strings
parent e060123a
No related merge requests found
...@@ -438,9 +438,9 @@ lex_keyword buf = ...@@ -438,9 +438,9 @@ lex_keyword buf =
Just xx -> xx : lexIface (stepOverLexeme buf') Just xx -> xx : lexIface (stepOverLexeme buf')
lex_decl buf = lex_decl buf =
case expandUntilMatch buf ";;" of case doDiscard False buf of -- spin until ;; is found
buf' -> buf' ->
-- _trace (show (lexemeToString buf')) $ {- _trace (show (lexemeToString buf')) $ -}
case currentChar# buf' of case currentChar# buf' of
'\n'# -> -- newline, no id info. '\n'# -> -- newline, no id info.
ITtysig (lexIface (lexemeToBuffer (decLexeme buf'))) : ITtysig (lexIface (lexemeToBuffer (decLexeme buf'))) :
...@@ -452,7 +452,7 @@ lex_decl buf = ...@@ -452,7 +452,7 @@ lex_decl buf =
ITtysig (lexIface (lexemeToBuffer (decLexeme buf'))) : ITtysig (lexIface (lexemeToBuffer (decLexeme buf'))) :
lexIface (stepOverLexeme buf') lexIface (stepOverLexeme buf')
c -> -- run all over the id info c -> -- run all over the id info
case expandUntilMatch (stepOverLexeme buf') ";;" of case doDiscard False (stepOverLexeme buf') of -- spin until ;; is found (outside a string!)
buf'' -> buf'' ->
--_trace ((C# c):show (lexemeToString (decLexeme buf'))) $ --_trace ((C# c):show (lexemeToString (decLexeme buf'))) $
--_trace (show (lexemeToString (decLexeme buf''))) $ --_trace (show (lexemeToString (decLexeme buf''))) $
...@@ -763,13 +763,24 @@ haskellKeywordsFM = listToUFM $ ...@@ -763,13 +763,24 @@ haskellKeywordsFM = listToUFM $
-- doDiscard rips along really fast looking for a double semicolon, -- doDiscard rips along really fast looking for a double semicolon,
-- indicating the end of the pragma we're skipping -- indicating the end of the pragma we're skipping
doDiscard buf = doDiscard inStr buf =
-- _trace (show (C# (currentChar# buf))) $
case currentChar# buf of case currentChar# buf of
';'# -> ';'# ->
case lookAhead# buf 1# of if not inStr then
';'# -> stepOnBy# buf 2# case lookAhead# buf 1# of
_ -> doDiscard (stepOn buf) ';'# -> incLexeme (incLexeme buf)
_ -> doDiscard (stepOn buf) _ -> doDiscard inStr (incLexeme buf)
else
doDiscard inStr (incLexeme buf)
'"'# ->
case lookAhead# buf (negateInt# 1#) of --backwards, actually
'\\'# -> -- false alarm, escaped.
doDiscard inStr (incLexeme buf)
_ -> case inStr of -- forced to avoid build-up
True -> doDiscard False (incLexeme buf)
False -> doDiscard True (incLexeme buf)
_ -> doDiscard inStr (incLexeme buf)
\end{code} \end{code}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment