3 ms·
> I lament that I cannot use something regex-like to match general sequences, e.g. a sequence of tokens You can. It's not typically built into a programming la
by mumblemumble 5y ago
> I lament that I cannot use something regex-like to match general sequences, e.g. a sequence of tokens
You can. It's not typically built into a programming language's standard library. But there are plenty of general-purpose automata-building libraries out there, and some of them do provide DSLs. At least to the extent that the regular expressions you're using are actually regular (many aren't), all a regex is is a domain-specific specialization of nondeterministic finite automata.
I sometimes lament that I don't see them, or hand-coded automata, more often. This was CS101-level stuff when I was in college, and it's pretty easy to code your own even if you don't have a good library available in your language. And, for problems where they're appropriate, using them typically yields a result that's simpler and easier to maintain than whatever ad-hoc alternative you might see instead.