I'm planing to write a (very simple) two pass assembler (mostly as an example) using PLY. The passes will obviously share lexical and syntax, but the actions attached will be very different (the first pass just collects label definitions, updating addresses only, and calculates expressions --restricting expressions to only use already defined labels is not terrible, and sidesteps having to set up equations and solve them--; the second pass uses the data collected by the first pass to write out the object file).
The obvious way to do this is to just write the whole stuff twice, but that just grates me wrong (any change will have to be done twice, and that just calls for trouble). Having the actions littered with if pass == 1: and so is also ugly.