State Machine Compiler using templates