Skip to content

Implementation of string is not ideal #92

Closed
@natefaubion

Description

@natefaubion

string :: forall s m. StringLike s => Monad m => String -> ParserT s m String
string str = do
input <- gets \(ParseState input _ _) -> input
case indexOf (wrap str) input of
Just 0 -> do
modify_ \(ParseState _ position _) ->
ParseState (drop (length str) input)
(updatePosString position str)
true
pure str
_ -> fail ("Expected " <> show str)

This will perform a linear scan to find a match anywhere, before checking if that match is at index 0. It should probably just take whatever the length of the desired token is and check for eq.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions