Compare commits

..

5 commits

Author SHA1 Message Date
e9280d63f8
style(lexer): pluralize moduleNames parser 2025-09-24 20:51:05 +08:00
20b5ffac36
ref(moduleName): break into multiple smaller functions
upperId has been changed to only use isUpper because an non alphabetical
character would be false anyway
2025-09-24 20:47:55 +08:00
c956c97e0c
ref(lexer): simplify anchor 2025-09-24 20:25:48 +08:00
064e253f03
ref(lexer): simplify delimited logic 2025-09-24 20:25:14 +08:00
678158d614
fix(lexer): handle crlf in newline
Do we support windows 🤔
2025-09-24 18:35:15 +08:00
2 changed files with 1 additions and 3 deletions

View file

@ -221,7 +221,7 @@ link :: Lexer
link = do link = do
pos <- getPosition pos <- getPosition
l <- linkRaw l <- linkRaw
-- register the position of the last token -- "unconsume" the last token
pos' <- flip incSourceColumn (-1) <$> getPosition pos' <- flip incSourceColumn (-1) <$> getPosition
pure $ (pos, LinkOpen) : l <> [(pos', LinkClose)] pure $ (pos, LinkOpen) : l <> [(pos', LinkClose)]

View file

@ -11,7 +11,6 @@ import Types
import Data.String (IsString (..)) import Data.String (IsString (..))
import Data.Text (Text) import Data.Text (Text)
import Text.Parsec.Pos import Text.Parsec.Pos
import GHC.Stack
main :: IO () main :: IO ()
main = hspec $ do main = hspec $ do
@ -187,7 +186,6 @@ instance IsString (Doc String) where
shouldLexTo :: String -> [(Int, Int, Token)] -> Expectation shouldLexTo :: String -> [(Int, Int, Token)] -> Expectation
shouldLexTo input expected = shouldLexTo input expected =
withFrozenCallStack $
case lexer input of case lexer input of
Right tokens -> do Right tokens -> do
let actual = map (\(pos, tok) -> (sourceLine pos, sourceColumn pos, tok)) tokens let actual = map (\(pos, tok) -> (sourceLine pos, sourceColumn pos, tok)) tokens