diff options
Diffstat (limited to 'Rakefile')
| -rw-r--r-- | Rakefile | 38 |
1 files changed, 28 insertions, 10 deletions
@@ -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 |
