Script to convert RouterOS firewall rules to native iptables and vice versa

Does anybody know of a script or method to automatically convert RouterOS firewall rules to native iptables and vice versa?

I have a list of RouterOS rules for both IPv4 and IPv6 that I need to convert to native iptables syntax: https://pastebin.com/j3EVPzp0

Doing it manually has proven difficult.