marrub
/
Lithia
Archived
1
0
Fork 0
This repository has been archived on 2023-06-17. You can view files and clone it, but cannot push or open issues/pull-requests.
Lithia/decompat.rb

26 lines
614 B
Ruby

#!/usr/bin/env ruby
## Copyright © 2017 Graham Sanderson
## DeCompat: ZScript ↔ DECORATE shared syntax preprocessor.
def todec fp, out
for ln in fp
ln = ln.chomp.sub(/<Actor>/, "actor").sub(/<Const>/, "const int")
if ln.include? "<Default>" or ln.include? "<EndDefault>" then next
elsif ln.include? "<States>"
out.write " states\n {\n"
elsif ln.include? "<EndStates>"
out.write " }\n"
else
out.write ln + "\n"
end
end
end
for arg in ARGV
fp = open(arg, "rt")
dec = fp.gets[15..-1].chomp
todec fp, open(dec, "wt")
end
## EOF