Make procedure name after the end

This commit is contained in:
2025-05-29 14:59:56 +02:00
parent 192e7e40c8
commit bd41736697
6 changed files with 410 additions and 377 deletions

View File

@ -15,11 +15,11 @@ CLEAN.include 'build'
rule(/build\/stage1\/.+\.o$/ => ->(file) {
path = Pathname.new('boot/stage1/source') + Pathname.new(file).basename
['build/stage1', path.sub_ext('.def'), path.sub_ext('.elna')]
['build/stage1', path.sub_ext('.def'), path.sub_ext('.mod')]
}) do |t|
sources = t.prerequisites.filter { |f| f.end_with? '.elna' }
sources = t.prerequisites.filter { |f| f.end_with? '.mod' }
sh M2C, '-fmod=.elna', '-c', '-I', 'boot/stage1/source', '-o', t.name, *sources
sh M2C, '-c', '-I', 'boot/stage1/source', '-o', t.name, *sources
end
file 'build/stage1/elna' => FileList['boot/stage1/source/*'].map { |file|
@ -28,10 +28,10 @@ file 'build/stage1/elna' => FileList['boot/stage1/source/*'].map { |file|
sh M2C, '-o', t.name, *t.prerequisites
end
file 'build/stage1/Compiler.o' => ['build/stage1', 'boot/stage1/source/Compiler.elna'] do |t|
sources = t.prerequisites.filter { |f| f.end_with? '.elna' }
file 'build/stage1/Compiler.o' => ['build/stage1', 'boot/stage1/source/Compiler.mod'] do |t|
sources = t.prerequisites.filter { |f| f.end_with? '.mod' }
sh M2C, '-fscaffold-main', '-fmod=.elna', '-c', '-I', 'boot/stage1/source', '-o', t.name, *sources
sh M2C, '-fscaffold-main', '-c', '-I', 'boot/stage1/source', '-o', t.name, *sources
end
['source', 'self'].each do |sub|
@ -98,8 +98,10 @@ task :backport do
FileList['source/*.elna'].each do |file|
source_path = Pathname.new file
source = File.read source_path
current_procedure = nil
target = ''
target = source
source
.gsub(/^(var|type|const|begin)/) { |match| match.upcase }
.gsub(/^[[:alnum:]]* ?module/) { |match| match.upcase }
.gsub(/\brecord\b/) { |match| match.upcase }
@ -109,8 +111,22 @@ task :backport do
.gsub(/^from ([[:alnum:]]+) import/, 'FROM \1 IMPORT')
.gsub(/ \^([[:alnum:]])/, ' POINTER TO \1')
.gsub(/(then|do)$/) { |match| match.upcase }
.each_line do |line|
if line.start_with? 'PROCEDURE'
current_procedure = line[10...line.index('(')]
elsif line.start_with?('END;') && !current_procedure.nil?
line = "END #{current_procedure};"
current_proceure = nil
elsif line.start_with?('end')
line = 'END ' + line[4..]
end
target += line
end
target_path = Pathname.new('boot/stage1/source') + source_path.basename
target_path = Pathname.new('boot/stage1/source') + source_path.basename.sub_ext('.mod')
File.write target_path, target
end
FileList['source/*.def'].each do |file|
cp file, File.join('boot/stage1/source', Pathname.new(file).basename)
end
end