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