Implement 2 word argument support

This commit is contained in:
2026-05-29 01:05:34 +02:00
parent b09ddfcbbe
commit 7401038971
2 changed files with 175 additions and 46 deletions
+28 -10
View File
@@ -37,18 +37,36 @@ end
desc 'Convert previous stage language into the current stage language'
task :convert do
File.open('boot/stage23/cl.elna', 'w') do |current_stage|
seen_var = false
seen_proc = false
File.readlines('boot/stage22/cl.elna').each do |line|
if line.start_with? 'var'
seen_var = true
current_stage << "var\n"
elsif line.start_with? 'begin'
seen_var = false
current_stage << "begin\n"
elsif seen_var && line.end_with?(";\n")
current_stage << line[0..-3]
current_stage << "\n"
if line.start_with? 'proc'
seen_proc = true
current_stage << line
elsif seen_proc && line.start_with?('begin')
seen_proc = false
current_stage << line
elsif !seen_proc && line.start_with?('begin')
current_stage << <<~CODE
proc g(location: ElnaLocation)
begin
\tprintf("# %i %i\\n\\0", location.line, location.column)
end
proc f()
var
\tlocation: ElnaLocation
begin
\tlocation.line := 2;
\tlocation.column := 3;
\tg(location)
end
CODE
current_stage << line
current_stage << <<~CODE
\tf();
CODE
else
current_stage << line
end