Add a command line parsing procedure

This commit is contained in:
2025-05-31 11:28:24 +02:00
parent 6e415e474f
commit 1983ef8e71
13 changed files with 1097 additions and 412 deletions

View File

@ -44,11 +44,12 @@ end
.partition { |f| f.end_with? '.elna' }
File.open t.name, 'w' do |output|
puts
puts(compiler * ' ')
compiler_command = compiler + sources
Open3.popen2(*compiler) do |cl_in, cl_out|
cl_in.write File.read(*sources)
puts
puts(compiler_command * ' ')
Open3.popen2(*compiler_command) do |cl_in, cl_out|
cl_in.close
IO.copy_stream cl_out, output
@ -87,11 +88,11 @@ task default: 'source/Compiler.elna'
task :default do |t|
exe, previous_output, source = t.prerequisites
cat_arguments = ['cat', source]
exe_arguments = [exe, source]
diff_arguments = ['diff', '-Nur', '--text', previous_output, '-']
puts [cat_arguments * ' ', exe, diff_arguments * ' '].join(' | ')
Open3.pipeline(cat_arguments, exe, diff_arguments)
puts [exe, diff_arguments * ' '].join(' | ')
Open3.pipeline exe_arguments, diff_arguments
end
task :backport do
@ -104,7 +105,7 @@ task :backport do
source
.gsub(/^(var|type|const|begin)/) { |match| match.upcase }
.gsub(/^[[:alnum:]]* ?module/) { |match| match.upcase }
.gsub(/\b(record|nil|or)\b/) { |match| match.upcase }
.gsub(/\b(record|nil|or|false|true)\b/) { |match| match.upcase }
.gsub(/proc\(/, 'PROCEDURE(')
.gsub(/ & /, ' AND ')
.gsub(/ -> /, ': ')