In sleeping on it and having a job, that frankly leaves my mind free: I've come up with an idea for the tpsh problem.
The tokenizer is beautiful, the only problem is it does the expansions through a table of call backs. Now if I was to modify that so that it instead attaches meta-data to each token instead, those expansions could be delayed until later without major redesign. It will be necessary to redactor the lexer in order to handle the change in data structure. The code generator can then be tasked with completing any expansions during generation, by expanding lexemes to corrisponding code as it goes. After wards, re do the code generate into something more elegant and voila.... we have what it should've been in the first place!
A good nights sleep always helps the code[r]