summaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2025-11-07 09:56:50 +0100
committerEugen Wissner <belka@caraus.de>2025-11-07 09:57:44 +0100
commit0b516345666b52d29bb10521b4d3c2c2420b3368 (patch)
treeb0e26ba2e981efae2805fa360a67dbf58224bbdd /Rakefile
parent63c211a8e97c7af69d6faf4fe3d2c1caecc35f25 (diff)
downloadelna-0b516345666b52d29bb10521b4d3c2c2420b3368.tar.gz
Generate record accessors automatically
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile44
1 files changed, 35 insertions, 9 deletions
diff --git a/Rakefile b/Rakefile
index 9d866ea..ec3ae04 100644
--- a/Rakefile
+++ b/Rakefile
@@ -41,17 +41,43 @@ end
desc 'Convert previous stage language into the current stage language'
task :convert do
- File.open('boot/stage14.elna', 'w') do |current_stage|
- previous_line = nil
-
- File.readlines('boot/stage13.elna').each do |line|
- if !previous_line.nil? && previous_line.start_with?('begin') && line.strip.start_with?('return')
- else
- current_stage << previous_line unless previous_line.nil?
+ File.open('boot/stage16.elna', 'w') do |current_stage|
+ skip = false
+
+ File.readlines('boot/stage15.elna').each do |line|
+ if line.strip == 'type'
+ current_stage << <<~SNIP
+ type
+ _elna_tac_declaration = record
+ next: Word;
+ name: Word;
+ length: Word;
+ body: Word
+ end;
+ _integer_literal_node = record
+ kind: Word;
+ value: Word;
+ length: Word
+ end;
+ SNIP
+ elsif line.start_with?('proc _elna_tac_declaration_size')
+ skip = true
+ elsif line.start_with?('proc _elna_tac_declaration_get_')
+ skip = true
+ elsif line.start_with?('proc _elna_tac_declaration_set_')
+ skip = true
+ elsif line.start_with?('proc _integer_literal_node_size')
+ skip = true
+ elsif line.start_with?('proc _integer_literal_node_get_')
+ skip = true
+ elsif line.start_with?('proc _integer_literal_node_set_')
+ skip = true
+ elsif line.start_with?('end') && skip
+ skip = false
+ elsif !skip
+ current_stage << line
end
- previous_line = line
end
- current_stage << previous_line
end
end