Aaron N. Tubbs bio photo

Aaron N. Tubbs

Dragon chaser.

Twitter Facebook Google+ LinkedIn Github

I’ve flunked out of CPPGM. Technically speaking, that hasn’t quite happened yet, but as of PA6’s Sep-22 deadline, I’m not going to have a functioning PA6.

I failed because I didn’t budget enough time for PA6, and focused on end-of-year tasks at work instead. I assumed by burning hard on work up to mid-September, I would have some free time to get back to CPPGM. In reality I’m in Paris this week for work, California next week for work, and have had too much work work to do. It’s not work’s fault, just bad planning on my part.

As of last week I’d completed encoding the C++ grammar1 in my source code. There were a number of defects that I presumed were due to incorrectly transcribing the grammar, and a few things I had to still implement, but I thought I was in the home stretch.

Then, last night, I realized I still know nothing about compiler construction and there’s a big problem. Many of the grammar productions have things like:

  cast-operator cast-expression

The problem is that something like (x) looks like a unary-expression or a cast-operator. For those of you that have written more parsers than me, you’re probably saying “duh” right now. For many more obvious cases I didn’t fall into this trap – I caught most of the things that could be determined by single or dual-token lookahead and kept the parse path coincident until that point. But for more complicated constructs like these, about my only option to salvage what I have is to attempt a full parse of both and pick the longest one. Or to attempt promotion from one parse tree to another, but that’s got its own problems. In any event, within my current framework, working around this isn’t even particularly possible in the time frame I have left. C’est la vie.

Pretty disappointed in myself for failing this early in the program, but I’m not seeing a way out of that reality when combined with my schedule for the next few days. The course is not easy, but it’s set up well and I believe provides plenty of time, if you make enough time for it, and I didn’t.

  1. It’s not strictly accurate to say I’ve encoded the C++ grammar as much as I’d implemented parsing for Annex A.3 through A.13. This technically parses a superset of C++ syntax, since context is necessary to correctly parse it.