3 ms·
Without wanting to get into too much back and forth, a quick response to these: Parsing: hand writing lexers is an enormous PIA and the problem with a hand wri
by gchpaco 17y ago
Without wanting to get into too much back and forth, a quick response to these:
Parsing: hand writing lexers is an enormous PIA and the problem with a hand written recursive descent parser is if you want to change the grammar for whatever reason it is more involved than if you had a grammar generator.
Regexps: the problem with re.VERBOSE is that you're still writing essentially assembly language for a state machine, in the end, and it doesn't solve problems like "I want to search for this user input string, interpolate it into here and escape it for me please." Or even more interesting ones like "I want to compose these regexps, because I'm having to write a lexer by hand". You can use a separate escape function, and generally build up this layer of essentially scar tissue around the fact that this feature of your language is not really well integrated into the language, but that has its own issues. Better to solve it cleanly IMHO.
Databases: I have no experience with SQLAlchemy; it didn't exist when I did the DB project.
Continuations: I could probably have gotten away with using coroutines there. But Stackless was still an experiment, and not a particularly promising one, and generators didn't exist in the language at the time. I still think CPS-conversion would have been cleaner.
- limmeau 17y agoNow that you mention composable regexps (or composable grammars), I want some, too. :)
- silentbicycle 17y agoWell, if you're considering Lua, look at LPEG. (http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html)
- limmeau 17y ago(Answering myself,) apparently pyparsing[1] composes grammars from grammar objects in the spirit of parser combinators. [1] http://pyparsing.wikispaces.com/ http://pyparsing.wikispaces.com/