5 ms·
> * Regular expressions > * Parser combinators > * Parser generators I sometimes forget how I take regexes for granted, and how some people don't know them. I
by SamReidHughes 5y ago
> * Regular expressions
> * Parser combinators
> * Parser generators
I sometimes forget how I take regexes for granted, and how some people don't know them.
I would replace the combinator/generator stuff with "how to cleanly make a hand-written parser." Developers frequently stumble through that quite badly.
- ZeroCool2u 5y agoI'm actually just about to run into making a somewhat complex parser and haven't done it since school. Any recommendations resources you'd recommend as a refresher?
- SamReidHughes 5y agoBy basics I really mean extreme basics. The level of instruction I'm thinking is: <begin> A parser is a function that looks something like "optional<Foo> parse_foo(const std::string& data, size_t *pos)", which increases the value of *pos. It chews off objects from the front of the string and returns std::nullopt upon error. It's easy to recursively invoke smaller parsers this way. <end> Just that alone would really help people out and avoid problems I've seen encountered, where a dev needs to parse something, and just kind of spastically traipses around the string.
- ZeroCool2u 5y agoAh, well I’ve got that bit covered at the very least :)
- screye 5y agoYou don't even need to know how to use regex well. If you know what to look for, tools like regexr.com practically create the regex for you. I have often found that the ability to identify : "hey I can use regex here", is more useful than actually knowing how to use regex.