Thanks for all the replies and ideas, plenty to think about. I've just found and read the section 4.18 'Conditional lexing and start conditions' in 'ply.html'. This is about conditional lexing and states in the lexer so probably the way to go. My initial thought is to have one state that matches a 'token' up to a #rom token (easy enough with a Python re), pass all this other 'C' code to the parser as the single token and switch lexer state to a #rom tokenising state. At the end of the #rom statement a parser rule action will have to switch the lexer state back. This approach has the advantage that all output goes through the parser and all interaction with the lexer is at the published interface level.
Definitely make the '#rom locateHi|Lo @ addr' statement explicitly terminated. ';' is 'C' like and seems good to me. Hopefully this will stop the parser having to read a lookahead token as dangyogi pointed out. Will do these mods but not sure when. I don't know if it would be feasible to turn it into a general purpose pre-processor as an m4 alternative but it could certainly be a customisable frame work. Thanks again everyone. John -- You received this message because you are subscribed to the Google Groups "ply-hack" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ply-hack/5d3ea75c-e02c-4ba2-bc08-f1d0c6619446%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
