A toy compiler front end for a subset of C in my compilers course
The sharer walked through this project in their Google internship interviews and went on to receive the offer.
Step into this interview
4 real follow-ups from the actual loop · 2 hard · ~12 min
You answer each question first — only then does the sharer's real take open up.
How they told it
I wrote the lexer and parser for a compilers-course project targeting a subset of C. The interview zoomed in on one decision: why recursive descent, and where my grammar quietly cheated.
Read the full telling
This was my compilers course project. The goal was a working front end for a small subset of C, ending in an AST, and a partner handled codegen to a stack-based IR while I did the lexer and parser. I wrote the lexer by hand and the parser as recursive descent. I picked recursive descent over a parser generator mostly because I understood it and could debug it, and the grammar was small enough that it didn't matter. Where I cut corners: expression precedence. Instead of encoding the full C precedence table cleanly, I hardcoded a handful of levels and just didn't support some operators, and my error messages were bad, they'd point at the wrong token. We ran it on the course test cases and it passed most of them; nobody outside the class used it. In the interview the follow-ups got specific fast, especially on how I handled operator precedence and left recursion. I was honest that I used precedence climbing for the levels I did support and simply omitted operators I didn't have time for, rather than claiming full coverage. The thing that seemed to land was being able to say precisely what the parser did and did not accept, and admitting the error handling was the weakest part.
What they actually got asked
Why recursive descent instead of a parser generator like yacc?
easyHow did you handle operator precedence and associativity?
hardRecursive descent can't handle left recursion directly. Where did that bite you?
hardWhat was the weakest part, and what would you fix first?
medium