Implement array access expressions
This commit is contained in:
46
Rakefile
46
Rakefile
@@ -38,10 +38,47 @@ end
|
||||
|
||||
desc 'Convert previous stage language into the current stage language'
|
||||
task :convert do
|
||||
File.open('boot/stage18/cl.elna', 'w') do |current_stage|
|
||||
File.readlines('boot/stage17/cl.elna').each do |line|
|
||||
File.open('boot/stage19/cl.elna', 'w') do |current_stage|
|
||||
File.readlines('boot/stage18/cl.elna').each do |line|
|
||||
current_stage << "\tf();\n" if line.include? "if _compile() then"
|
||||
current_stage << line
|
||||
if line == "type\n"
|
||||
current_stage << <<-RECORD
|
||||
Pair = record
|
||||
first: Word;
|
||||
second: Word
|
||||
end;
|
||||
R1 = record
|
||||
field1: Word;
|
||||
field2: [4]Word;
|
||||
field3: Word
|
||||
end;
|
||||
R2 = record
|
||||
field1: Word;
|
||||
field3: Word;
|
||||
field4: Word;
|
||||
field5: Word;
|
||||
field6: Word;
|
||||
field2: Word
|
||||
end;
|
||||
|
||||
RECORD
|
||||
end
|
||||
end
|
||||
current_stage << <<~EPILOGUE
|
||||
|
||||
proc f();
|
||||
var
|
||||
v1: Word;
|
||||
r: ^R1;
|
||||
begin
|
||||
r := malloc(#size(R1));
|
||||
|
||||
v1 := r^.field2[2];
|
||||
|
||||
printf("# %i\\n\\0", v1)
|
||||
end;
|
||||
EPILOGUE
|
||||
end
|
||||
end
|
||||
|
||||
@@ -105,7 +142,10 @@ file 'build/build.ninja' => ['build'] do |t|
|
||||
build #{valid_stage}/cl: #{link} #{valid_stage}/cl.o
|
||||
NINJA
|
||||
end
|
||||
f << "\ndefault build/valid/stage18/cl\n"
|
||||
f << <<~NINJA
|
||||
|
||||
default build/valid/#{STAGES.last}/cl
|
||||
NINJA
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user