Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I mean, with enough hacking around, anything can work. But the code had gotten extremely complicated and brittle, and it was still not handling all the edge cases. Readability was important for this project, since I want to be able to modify the parser later to add new extensions to the language.


Ah gotcha, thanks! Out of curiosity do you recall examples of any of the hardest cases it couldn't properly handle?


Stuff like:

    char *(*(**foo[][8])())[]


And it would fail to parse at all, or parse as the wrong thing?


Recursive descent required too much backtracking and state resets, which made the code buggy and unreadable (and the error reporting was awful). Pratt parser simply parsed wrong (presumably because I couldn't figure out the right way to sort the precedences).


Gotcha! I've been thinking of trying my hand at a C parser but it always gave me the sense that it was more annoying than it should be haha. Interesting to near your experience, thanks for sharing!




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: