Skip to content

Commit

Permalink
Require repl and convert \r\n to \n in lexer
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Jul 17, 2024
1 parent 551219f commit 70fc3af
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
1 change: 0 additions & 1 deletion cryptol-remote-api/src/CryptolServer/FocusedModule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Data.Aeson as JSON

import Cryptol.ModuleSystem (meFocusedModule, meLoadedModules)
import Cryptol.ModuleSystem.Env (isLoadedParamMod)
import qualified Cryptol.TypeCheck.AST as T
import Cryptol.Utils.PP

import CryptolServer
Expand Down
5 changes: 4 additions & 1 deletion src/Cryptol/Parser/LexerUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,10 @@ alexGetByte i =
do (c,rest) <- T.uncons (input i)
let i' = i { alexPos = move (alexPos i) c, input = rest }
b = byteForChar c
return (b,i')
-- treat \r\n as \n
case (b, alexGetByte i') of
(13, skip@(Just (10, _))) -> skip
_ -> pure (b, i')

data Layout = Layout | NoLayout

Expand Down
2 changes: 1 addition & 1 deletion src/Cryptol/REPL/Command.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2012,7 +2012,7 @@ extractCodeBlocks raw = go [] cleanLines
go finished (x:xs)
| (ticks, lang) <- T.span ('`' ==) x
, 3 <= T.length ticks
= if lang `elem` ["", "repl"]
= if lang == "repl"
then keep finished ticks [] xs
else skip finished ticks xs
| otherwise = go finished xs
Expand Down
4 changes: 2 additions & 2 deletions tests/docstrings/T01.cry
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module T01 where
submodule Sub where
/**
* This verifies that pp shadows the outer definition
* ```
* ```repl
* :check pp
* ```
*/
pp = True

/**
* ```
* ```repl
* :check ~ pp
* ```
*/
Expand Down
7 changes: 4 additions & 3 deletions tests/docstrings/T02.cry
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ submodule F where
c = 1

/**
* ```
* Longer code block delimiters are supported
* ````repl
* :exhaust p
* ```
* ````
*/
p x = c + x == x + c

submodule F7 = submodule F where
type n = 7

/**
* ```
* ```repl
* let y = 20
* :check f 10 == 20
* ```
Expand Down
5 changes: 5 additions & 0 deletions tests/docstrings/T04.cry
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ module T03 where
* ```repl
* :load AFile.cry
* ```
*
* Stuff not marked repl is ignored
* ```
* garbage
* ```
*/
a : Bit
a = True

0 comments on commit 70fc3af

Please sign in to comment.