First stab at conditional compilation

Seems to be working, might need a more robust test suite. Could you review and let me know if I'm doing anything stupid? I think there might still be some confusion RE `peek()` vs `next()` in some places.