I'm imagining as years go by when/if this AI regex code breaks - nobody knows how it works or how to fix it. Am I wrong?
I'm not a programmer and I write shitty code but I can manage to write simple regex to create quick and dirty code. That's a terrible programming choice I know but I never share my code. It's just for me and it works.
How does this method handle backtracking? It seems like, as written, those functions wouldn’t handle it
Some implementations don't support backtracking at all, but ones that do will have combinators like
atomic parserA <|> atomic parserB <|> parserC -- equivalent to choice [parserA, parserB, parserC]
where
atomic
andchoice
are parsers that take other parsers as arguments likeand
andor
in the article, though the advice is to avoid backtracking whenever possible since it's quite expensive. The little examples in the post are just a taste to make the idea legible, but not really suited for especially interesting parsers.