summaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2025-09-10 23:57:56 +0200
committerEugen Wissner <belka@caraus.de>2025-09-11 13:05:04 +0200
commit216dc59f0b1507a7529ce34332463f9443a05cd4 (patch)
tree547d9d7ea7a72095a830bdd03ab6f1259e204df9 /Rakefile
parentd16ec370dc000e81978853661bbc7f5dac803975 (diff)
downloadelna-216dc59f0b1507a7529ce34332463f9443a05cd4.tar.gz
Support comments between (* and *)
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile47
1 files changed, 10 insertions, 37 deletions
diff --git a/Rakefile b/Rakefile
index 55f9f01..32157d0 100644
--- a/Rakefile
+++ b/Rakefile
@@ -14,7 +14,7 @@ directory 'build/boot'
directory 'build/valid'
def compile(input, output)
- sh ENV.fetch('CC', 'gcc'), '-nostdlib', '-o', output, input
+ sh ENV.fetch('CC', 'gcc'), '-nostdlib', '-fpie', '-g', '-o', output, input
end
def run(exe)
@@ -39,43 +39,16 @@ end
desc 'Convert previous stage language into the current stage language'
task :convert do
- File.open('boot/stage8.elna', 'w') do |current_stage|
- File.readlines('boot/stage7.elna').each do |line|
- if line == ".section .bss\n"
- current_stage << <<~SECTION
- const
- symbol_builtin_name_int := "Int";
- symbol_builtin_name_word := "Word";
- symbol_builtin_name_pointer := "Pointer";
- symbol_builtin_name_char := "Char";
- symbol_builtin_name_bool := "Bool";
-
- # Every type info starts with a word describing what type it is.
- #
- # PRIMITIVE_TYPE = 1
- #
- # Primitive types have only type size.
- symbol_builtin_type_int := S(1, 4);
- symbol_builtin_type_word := S(1, 4);
- symbol_builtin_type_pointer := S(1, 4);
- symbol_builtin_type_char := S(1, 1);
- symbol_builtin_type_bool := S(1, 1);
-
- # Info objects start with a word describing its type.
- #
- # INFO_TYPE = 1
- #
- # Type info has the type it belongs to.
- symbol_type_info_int := S(1, @symbol_builtin_type_int);
- symbol_type_info_word := S(1, @symbol_builtin_type_word);
- symbol_type_info_pointer := S(1, @symbol_builtin_type_pointer);
- symbol_type_info_char := S(1, @symbol_builtin_type_char);
- symbol_type_info_bool := S(1, @symbol_builtin_type_bool);
- SECTION
- elsif line == ".section .data\n"
- current_stage << "var\n"
- elsif !(line == ".section .text\n" || line == ".globl _start\n")
+ File.open('boot/stage9.elna', 'w') do |current_stage|
+ File.readlines('boot/stage8.elna').each do |line|
+ comment_match = /^(\s*)#(.*)/.match line
+
+ if comment_match.nil?
current_stage << line
+ elsif comment_match[2].empty?
+ current_stage << "\n"
+ else
+ current_stage << "#{comment_match[1]}(* #{comment_match[2].strip} *)\n"
end
end
end