Transpile the global var section

This commit is contained in:
2025-05-27 17:05:00 +02:00
parent 3d401e7dac
commit 46d89122e4
4 changed files with 83 additions and 11 deletions

View File

@ -93,3 +93,20 @@ task :default do |t|
puts [cat_arguments * ' ', exe, diff_arguments * ' '].join(' | ')
Open3.pipeline(cat_arguments, exe, diff_arguments)
end
task :backport do
FileList['source/*.elna'].each do |file|
source_path = Pathname.new file
source = File.read source_path
target = source
.gsub(/^(var|type|const)/) { |match| match.upcase }
.gsub(/^[[:alnum:]]* ?module/) { |match| match.upcase }
.gsub(/(procedure|record| pointer to )/) { |match| match.upcase }
.gsub(/([[:space:]]*)end;/, '\1END;')
.gsub(/^from ([[:alnum:]]+) import/, 'FROM \1 IMPORT')
target_path = Pathname.new('boot/stage1/source') + source_path.basename
File.write target_path, target
end
end