Convert repeat rules into pairs of recursive rules
Refactor extract tokens function