4 ms·
Parsing C++ is not that hard if you use hand rolled recursive descent parser. On the other hand hacking some parser generator framework to be able to parse C++
by dfox 7y ago
Parsing C++ is not that hard if you use hand rolled recursive descent parser. On the other hand hacking some parser generator framework to be able to parse C++ is hard and IMO mostly pointless busywork.
- chrisseaton 7y ago> hacking some parser generator framework ... is hard and IMO mostly pointless busywork Bingo. We spent decades formalising and automating something... that was never that hard in the first place.
- dfox 7y agoIn context of parsing the situation when all the state machine/language theory has it's place is when you have some reason to care about compiler passes and generate output while reading input. That is, when you are not constructing some intermediate in-memory representation of whole compilation unit, presumably because you are running on system with (very) limited memory. For programming language compilers this ceased to be interesting limitation in 80's.
- nemoniac 7y agoNot that hard? It's literally undecidable! https://news.ycombinator.com/item?id=21154565 https://news.ycombinator.com/item?id=21154565
- chrisseaton 7y agoThat's not what 'hard' means in this context. Requiring template instantiation (or some other interplay I'm not aware of) doesn't make parsing harder - it just means it can't be done independently. And what's more that kind of interplay is easier outside a parser framework! Many languages are not very pure for parsing. If you're writing a parser using lex and bison this means bending over backwards to make it work.