Generate record accessors automatically
This commit is contained in:
42
Rakefile
42
Rakefile
@@ -41,17 +41,43 @@ end
|
|||||||
|
|
||||||
desc 'Convert previous stage language into the current stage language'
|
desc 'Convert previous stage language into the current stage language'
|
||||||
task :convert do
|
task :convert do
|
||||||
File.open('boot/stage14.elna', 'w') do |current_stage|
|
File.open('boot/stage16.elna', 'w') do |current_stage|
|
||||||
previous_line = nil
|
skip = false
|
||||||
|
|
||||||
File.readlines('boot/stage13.elna').each do |line|
|
File.readlines('boot/stage15.elna').each do |line|
|
||||||
if !previous_line.nil? && previous_line.start_with?('begin') && line.strip.start_with?('return')
|
if line.strip == 'type'
|
||||||
else
|
current_stage << <<~SNIP
|
||||||
current_stage << previous_line unless previous_line.nil?
|
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
|
end
|
||||||
previous_line = line
|
|
||||||
end
|
end
|
||||||
current_stage << previous_line
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
1856
boot/stage15.elna
1856
boot/stage15.elna
File diff suppressed because it is too large
Load Diff
4772
boot/stage16.elna
Normal file
4772
boot/stage16.elna
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user