Skip to content

Commit 6c93300

Browse files
authored
Quick fix for #1158 (#1166)
* Update the style for Token.hs in eval plugin * Fix #1158
1 parent 57f28ff commit 6c93300

File tree

1 file changed

+23
-11
lines changed
  • plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Parse

1 file changed

+23
-11
lines changed

plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Parse/Token.hs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
{-# OPTIONS_GHC -Wwarn #-}
22

33
-- | Parse source code into a list of line Tokens.
4-
module Ide.Plugin.Eval.Parse.Token(Token(..),TokenS,tokensFrom,unsafeContent,isStatement,isTextLine,isPropLine,isCodeLine,isBlockOpen,isBlockClose) where
5-
6-
import Control.Monad.Combinators (skipManyTill, many, optional, (<|>))
4+
module Ide.Plugin.Eval.Parse.Token (
5+
Token(..),
6+
TokenS,
7+
tokensFrom,
8+
unsafeContent,
9+
isStatement,
10+
isTextLine,
11+
isPropLine,
12+
isCodeLine,
13+
isBlockOpen,
14+
isBlockClose
15+
) where
16+
17+
import Control.Monad.Combinators (many, optional, skipManyTill,
18+
(<|>))
19+
import Data.Functor (($>))
720
import Data.List (foldl')
8-
import Ide.Plugin.Eval.Parse.Parser (satisfy, Parser, alphaNumChar, char,
9-
letterChar, runParser, space,
10-
string, tillEnd)
21+
import Ide.Plugin.Eval.Parse.Parser (Parser, alphaNumChar, char,
22+
letterChar, runParser, satisfy,
23+
space, string, tillEnd)
1124
import Ide.Plugin.Eval.Types (Format (..), Language (..), Loc,
1225
Located (Located))
1326
import Maybes (fromJust, fromMaybe)
14-
import Data.Functor ( ($>) )
1527

1628
type TParser = Parser Char (State, [TokenS])
1729

@@ -60,7 +72,7 @@ isBlockOpen _ = False
6072

6173
isBlockClose :: Token s -> Bool
6274
isBlockClose BlockClose = True
63-
isBlockClose _ = False
75+
isBlockClose _ = False
6476

6577
unsafeContent :: Token a -> a
6678
unsafeContent = fromJust . contentOf
@@ -83,7 +95,7 @@ contentOf _ = Nothing
8395
8496
-}
8597
tokensFrom :: String -> [Loc (Token String)]
86-
tokensFrom = tokens . lines
98+
tokensFrom = tokens . lines . filter (/= '\r')
8799

88100
{- |
89101
>>> tokens ["-- |$setup >>> 4+7","x=11"]
@@ -135,9 +147,9 @@ tokens = concatMap (\(l, vs) -> map (Located l) vs) . zip [0 ..] . reverse . snd
135147

136148
-- | Parse a line of input
137149
aline :: State -> TParser
138-
aline InCode = optionStart <|> multi <|> singleOpen <|> codeLine
150+
aline InCode = optionStart <|> multi <|> singleOpen <|> codeLine
139151
aline InSingleComment = optionStart <|> multi <|> commentLine False <|> codeLine
140-
aline InMultiComment = multiClose <|> commentLine True
152+
aline InMultiComment = multiClose <|> commentLine True
141153

142154
multi :: TParser
143155
multi = multiOpenClose <|> multiOpen

0 commit comments

Comments
 (0)