Parse the variable part to AST

This commit is contained in:
2025-06-04 12:14:04 +02:00
parent 82f0d40a56
commit 7c12fc1364
5 changed files with 89 additions and 31 deletions

View File

@ -101,6 +101,7 @@ task :backport do
source = File.read source_path
current_procedure = nil
target = ''
module_name = source_path.basename.sub_ext('')
source
.gsub(/^(var|type|const|begin)/) { |match| match.upcase }
@ -109,7 +110,8 @@ task :backport do
.gsub(/proc\(/, 'PROCEDURE(')
.gsub(/ & /, ' AND ')
.gsub(/ -> /, ': ')
.gsub(/end\./, "END #{source_path.basename.sub_ext('')}.")
.gsub(/program;/, "MODULE #{module_name};")
.gsub(/end\./, "END #{module_name}.")
.gsub(/([[:space:]]*)end(;?)$/, '\1END\2')
.gsub(/^([[:space:]]*)(while|return|if)\b/) { |match| match.upcase }
.gsub(/^from ([[:alnum:]]+) import/, 'FROM \1 IMPORT')