Refactor scripts in Tools/peg_generator/scripts (GH-20401)

(cherry picked from commit ba6fd87e41dceb01dcdacc57c722aca12cde42a9)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
7 files changed