Remove need for trailing semicolons
This commit is contained in:
@@ -36,30 +36,19 @@ end
|
||||
|
||||
desc 'Convert previous stage language into the current stage language'
|
||||
task :convert do
|
||||
File.open('boot/stage22/cl.elna', 'w') do |current_stage|
|
||||
seen_proc = false
|
||||
seen_global_var = false
|
||||
File.readlines('boot/stage21/cl.elna').each do |line|
|
||||
seen_proc = true if line.start_with? 'proc'
|
||||
seen_proc = false if line.start_with? 'end'
|
||||
if line.start_with?('begin') && !seen_proc
|
||||
current_stage << <<~FUN
|
||||
proc f();
|
||||
var
|
||||
x: ElnaRtlObjectInfo;
|
||||
begin
|
||||
x.allocated := true
|
||||
end;
|
||||
File.open('boot/stage23/cl.elna', 'w') do |current_stage|
|
||||
seen_var = false
|
||||
|
||||
begin
|
||||
f();
|
||||
FUN
|
||||
elsif line.start_with?('var') && !seen_global_var
|
||||
current_stage << <<~FUN
|
||||
var
|
||||
FUN
|
||||
elsif line.end_with?("allocated: Word\n")
|
||||
current_stage << "\t\tallocated: Bool\n"
|
||||
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"
|
||||
else
|
||||
current_stage << line
|
||||
end
|
||||
|
||||
+20
-8
@@ -3991,10 +3991,16 @@ begin
|
||||
result^.parameters := parameter_head;
|
||||
|
||||
(* Skip semicolon or arrow. *)
|
||||
token := elna_lexer_read(cursor);
|
||||
token := elna_lexer_peek(cursor);
|
||||
|
||||
if token^.kind = ElnaLexerKind.arrow then
|
||||
elna_lexer_read(cursor);
|
||||
result^.return_type := elna_parser_type_expression(cursor);
|
||||
token := elna_lexer_peek(cursor);
|
||||
if token^.kind = ElnaLexerKind.semicolon then
|
||||
elna_lexer_read(cursor)
|
||||
end
|
||||
elsif token^.kind = ElnaLexerKind.semicolon then
|
||||
elna_lexer_read(cursor)
|
||||
else
|
||||
result^.return_type := nil
|
||||
@@ -4270,8 +4276,10 @@ begin
|
||||
current_declaration := parser_node;
|
||||
|
||||
(* Skip semicolon. *)
|
||||
elna_lexer_read(cursor);
|
||||
|
||||
token := elna_lexer_peek(cursor);
|
||||
if token^.kind = ElnaLexerKind.semicolon then
|
||||
elna_lexer_read(cursor)
|
||||
end;
|
||||
goto elna_parser_procedures_loop
|
||||
end;
|
||||
return result
|
||||
@@ -4393,8 +4401,10 @@ begin
|
||||
elna_lexer_read(cursor);
|
||||
result^.type_expression := elna_parser_type_expression(cursor);
|
||||
|
||||
elna_lexer_read(cursor);
|
||||
|
||||
token := elna_lexer_peek(cursor);
|
||||
if token^.kind = ElnaLexerKind.semicolon then
|
||||
elna_lexer_read(cursor);
|
||||
end;
|
||||
return result
|
||||
end;
|
||||
|
||||
@@ -4512,8 +4522,10 @@ begin
|
||||
variable_node := elna_parser_variable_declaration(cursor);
|
||||
|
||||
(* Skip semicolon. *)
|
||||
elna_lexer_read(cursor);
|
||||
|
||||
token := elna_lexer_peek(cursor);
|
||||
if token^.kind = ElnaLexerKind.semicolon then
|
||||
elna_lexer_read(cursor)
|
||||
end;
|
||||
if result = nil then
|
||||
result := variable_node
|
||||
else
|
||||
@@ -6032,4 +6044,4 @@ begin
|
||||
else
|
||||
exit(4)
|
||||
end
|
||||
end;
|
||||
end.
|
||||
|
||||
+990
-998
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user