86
submitted 3 weeks ago* (last edited 3 weeks ago) by InevitableSwing@hexbear.net to c/askchapo@hexbear.net

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.

you are viewing a single comment's thread
view the rest of the comments
[-] stigsbandit34z@hexbear.net 5 points 3 weeks ago

This sounds useful

How do I learn to do it

[-] Speaker@hexbear.net 8 points 3 weeks ago

Read this for a very light introduction to the concept, then type "parser combinator library " into a search engine and never maintain a regular expression again!

[-] TheDoctor@hexbear.net 2 points 3 weeks ago

How does this method handle backtracking? It seems like, as written, those functions wouldn’t handle it

[-] Speaker@hexbear.net 2 points 3 weeks ago

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 and choice are parsers that take other parsers as arguments like and and or 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.

this post was submitted on 01 Dec 2024
86 points (100.0% liked)

askchapo

22821 readers
169 users here now

Ask Hexbear is the place to ask and answer ~~thought-provoking~~ questions.

Rules:

  1. Posts must ask a question.

  2. If the question asked is serious, answer seriously.

  3. Questions where you want to learn more about socialism are allowed, but questions in bad faith are not.

  4. Try !feedback@hexbear.net if you're having questions about regarding moderation, site policy, the site itself, development, volunteering or the mod team.

founded 4 years ago
MODERATORS