refactor lexer #2

Merged
primrose merged 13 commits from primrose/haddock2:leana8959 into dev 2025-09-26 14:44:47 +00:00
Collaborator

Reduce manual usage of getPosition and setting it and improve some helper functions.

Reduce manual usage of getPosition and setting it and improve some helper functions.
primrose added 4 commits 2025-09-24 12:50:26 +00:00
Do we support windows 🤔
upperId has been changed to only use isUpper because an non alphabetical
character would be false anyway
primrose changed title from WIP: leana8959 to WIP: refactor lexer 2025-09-24 12:50:36 +00:00
primrose added 1 commit 2025-09-24 12:51:30 +00:00
primrose changed title from WIP: refactor lexer to refactor lexer 2025-09-24 13:00:56 +00:00
elland approved these changes 2025-09-24 13:14:49 +00:00
elland left a comment
Owner

Thank you so much!

Thank you so much!
src/Lexer.hs Outdated
@ -150,0 +137,4 @@
<*> located closeP
delimited :: Parser a -> Parser b -> Token -> Token -> Parser [LocatedToken]
delimited openP closeP openTok closeTok = asList <$> delimitedAsTuple (openTok <$ openP) (closeTok <$ closeP)
Owner

nice! do you want to do the same nice naming as delimitedAsTouple with open/close instead of a b?

nice! do you want to do the same nice naming as delimitedAsTouple with open/close instead of a b?
Author
Collaborator

That's a good idea, will do

That's a good idea, will do
src/Lexer.hs Outdated
@ -251,3 +247,3 @@
mathsParens :: Lexer
mathsParens = delimited (void $ "\\(") (void "\\)") MathsParenOpen MathsParenClose
mathsParens = delimited "\\(" "\\)" MathsParenOpen MathsParenClose
Owner

❤️

❤️
test/Spec.hs Outdated
@ -46,3 +46,2 @@
"\"MyModule.Name\""
`shouldLexTo` [ (1, 1, Module)
, (1, 2, Token "MyModule.Name")
`shouldLexTo` [ (1, 2, Module "MyModule.Name")
Owner

Now here I am a bit unsure about what we want. Should the position match the inner value or the delimiters?

Now here I am a bit unsure about what we _want_. Should the position match the inner value or the delimiters?
Author
Collaborator

I actually don't know, should we even keep the quotes?

I actually don't know, should we even keep the quotes?
Owner

I wouldn’t keep it bc we for some representations we don’t need it and we can recreate for the ones we do.

I wouldn’t keep it bc we for some representations we don’t need it and we can recreate for the ones we do.
test/Spec.hs Outdated
@ -111,3 +108,4 @@
`shouldLexTo` [ (1, 1, Escape)
, (1, 2, Token "(")
]
"\\(\r\n"
Owner

🫡

🫡
primrose force-pushed leana8959 from e9280d63f8 to 6c0b4a4288 2025-09-24 13:26:00 +00:00 Compare
primrose added 1 commit 2025-09-24 13:29:27 +00:00
primrose added 2 commits 2025-09-24 13:33:43 +00:00
primrose force-pushed leana8959 from bd07547e26 to c4d59d3236 2025-09-24 13:35:40 +00:00 Compare
primrose added 4 commits 2025-09-24 14:33:04 +00:00
primrose added 1 commit 2025-09-26 09:25:52 +00:00
primrose force-pushed leana8959 from 5073fc0e25 to 970b658926 2025-09-26 09:59:08 +00:00 Compare
primrose merged commit 6064afd0b9 into dev 2025-09-26 14:44:47 +00:00
primrose referenced this pull request from a commit 2025-09-26 14:44:48 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: elland/haddock2#2
No description provided.