Implement if-else

This commit is contained in:
2025-09-13 21:15:09 +02:00
parent 216dc59f0b
commit ee3b733a81
4 changed files with 1859 additions and 84 deletions

View File

@@ -6,7 +6,9 @@
require 'open3'
require 'rake/clean'
STAGES = Dir.glob('boot/stage*.elna').collect { |stage| File.basename stage, '.elna' }.sort
STAGES = Dir.glob('boot/stage*.elna')
.collect { |stage| File.basename stage, '.elna' }
.sort { |a, b| a.delete_prefix('stage').to_i <=> b.delete_prefix('stage').to_i }
CLEAN.include 'build/boot', 'build/valid'
@@ -39,17 +41,9 @@ end
desc 'Convert previous stage language into the current stage language'
task :convert do
File.open('boot/stage9.elna', 'w') do |current_stage|
File.readlines('boot/stage8.elna').each do |line|
comment_match = /^(\s*)#(.*)/.match line
if comment_match.nil?
current_stage << line
elsif comment_match[2].empty?
current_stage << "\n"
else
current_stage << "#{comment_match[1]}(* #{comment_match[2].strip} *)\n"
end
File.open('boot/stage10.elna', 'w') do |current_stage|
File.readlines('boot/stage9.elna').each do |line|
current_stage << line
end
end
end