Add an empty cstdlib.elna source file
This commit is contained in:
@@ -36,19 +36,19 @@ begin
|
|||||||
parsed := GetArg(parameter, i);
|
parsed := GetArg(parameter, i);
|
||||||
parsed := false;
|
parsed := false;
|
||||||
|
|
||||||
if CompareStr(parameter, '--lex') = 0 then
|
if CompareStr(parameter, "--lex") = 0 then
|
||||||
parsed := true;
|
parsed := true;
|
||||||
result^.lex := true
|
result^.lex := true
|
||||||
end;
|
end;
|
||||||
if CompareStr(parameter, '--parse') = 0 then
|
if CompareStr(parameter, "--parse") = 0 then
|
||||||
parsed := true;
|
parsed := true;
|
||||||
result^.parse := true
|
result^.parse := true
|
||||||
end;
|
end;
|
||||||
if CompareStr(parameter, '-o') = 0 then
|
if CompareStr(parameter, "-o") = 0 then
|
||||||
i := i + 1u;
|
i := i + 1u;
|
||||||
|
|
||||||
if i = Narg() then
|
if i = Narg() then
|
||||||
WriteString(StdErr, 'Fatal error: expecting a file name following -o.');
|
WriteString(StdErr, "Fatal error: expecting a file name following -o.");
|
||||||
result := nil
|
result := nil
|
||||||
end;
|
end;
|
||||||
if i < Narg() then
|
if i < Narg() then
|
||||||
@@ -57,15 +57,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
parsed := true
|
parsed := true
|
||||||
end;
|
end;
|
||||||
if (parameter[1] <> '-') & (parsed = false) then
|
if (parameter[1] <> "-") & (parsed = false) then
|
||||||
parsed := true;
|
parsed := true;
|
||||||
|
|
||||||
if Length(result^.input) > 0 then
|
if Length(result^.input) > 0 then
|
||||||
WriteString(StdErr, 'Fatal error: only one source file can be compiled at once. First given "');
|
WriteString(StdErr, "Fatal error: only one source file can be compiled at once. First given \"");
|
||||||
WriteString(StdErr, result^.input);
|
WriteString(StdErr, result^.input);
|
||||||
WriteString(StdErr, '", then "');
|
WriteString(StdErr, "\", then \"");
|
||||||
WriteString(StdErr, parameter);
|
WriteString(StdErr, parameter);
|
||||||
WriteString(StdErr, '".');
|
WriteString(StdErr, "\".");
|
||||||
WriteLine(StdErr);
|
WriteLine(StdErr);
|
||||||
result := nil
|
result := nil
|
||||||
end;
|
end;
|
||||||
@@ -74,7 +74,7 @@ begin
|
|||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
if parsed = false then
|
if parsed = false then
|
||||||
WriteString(StdErr, 'Fatal error: unknown command line options: ');
|
WriteString(StdErr, "Fatal error: unknown command line options: ");
|
||||||
|
|
||||||
WriteString(StdErr, parameter);
|
WriteString(StdErr, parameter);
|
||||||
WriteChar(StdErr, '.');
|
WriteChar(StdErr, '.');
|
||||||
@@ -86,7 +86,7 @@ begin
|
|||||||
i := i + 1
|
i := i + 1
|
||||||
end;
|
end;
|
||||||
if (result <> nil) & (Length(result^.input) = 0) then
|
if (result <> nil) & (Length(result^.input) = 0) then
|
||||||
WriteString(StdErr, 'Fatal error: no input files.');
|
WriteString(StdErr, "Fatal error: no input files.");
|
||||||
WriteLine(StdErr);
|
WriteLine(StdErr);
|
||||||
result := nil
|
result := nil
|
||||||
end;
|
end;
|
||||||
|
@@ -25,9 +25,9 @@ begin
|
|||||||
source_input := OpenToRead(command_line^.input);
|
source_input := OpenToRead(command_line^.input);
|
||||||
|
|
||||||
if IsNoError(source_input) = false then
|
if IsNoError(source_input) = false then
|
||||||
WriteString(StdErr, 'Fatal error: failed to read the input file "');
|
WriteString(StdErr, "Fatal error: failed to read the input file \"");
|
||||||
WriteString(StdErr, command_line^.input);
|
WriteString(StdErr, command_line^.input);
|
||||||
WriteString(StdErr, '".');
|
WriteString(StdErr, "\".");
|
||||||
WriteLine(StdErr);
|
WriteLine(StdErr);
|
||||||
|
|
||||||
ExitOnHalt(2)
|
ExitOnHalt(2)
|
||||||
@@ -38,9 +38,9 @@ begin
|
|||||||
source_output := OpenToWrite(command_line^.output);
|
source_output := OpenToWrite(command_line^.output);
|
||||||
|
|
||||||
if IsNoError(source_output) = false then
|
if IsNoError(source_output) = false then
|
||||||
WriteString(StdErr, 'Fatal error: failed to create the output file "');
|
WriteString(StdErr, "Fatal error: failed to create the output file \"");
|
||||||
WriteString(StdErr, command_line^.output);
|
WriteString(StdErr, command_line^.output);
|
||||||
WriteString(StdErr, '".');
|
WriteString(StdErr, "\".");
|
||||||
WriteLine(StdErr);
|
WriteLine(StdErr);
|
||||||
|
|
||||||
ExitOnHalt(2)
|
ExitOnHalt(2)
|
||||||
|
@@ -26,7 +26,7 @@ begin
|
|||||||
count := 0;
|
count := 0;
|
||||||
|
|
||||||
while count < context^.indentation do
|
while count < context^.indentation do
|
||||||
WriteString(context^.output, ' ');
|
WriteString(context^.output, " ");
|
||||||
count := count + 1u
|
count := count + 1u
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
@@ -43,17 +43,17 @@ var
|
|||||||
written_bytes: Word;
|
written_bytes: Word;
|
||||||
current_symbol: ^Identifier;
|
current_symbol: ^Identifier;
|
||||||
begin
|
begin
|
||||||
WriteString(context^.output, 'FROM ');
|
WriteString(context^.output, "FROM ");
|
||||||
written_bytes := WriteNBytes(context^.output, ORD(import_statement^.package[1]), @import_statement^.package[2]);
|
written_bytes := WriteNBytes(context^.output, ORD(import_statement^.package[1]), @import_statement^.package[2]);
|
||||||
|
|
||||||
WriteString(context^.output, ' IMPORT ');
|
WriteString(context^.output, " IMPORT ");
|
||||||
|
|
||||||
current_symbol := import_statement^.symbols;
|
current_symbol := import_statement^.symbols;
|
||||||
written_bytes := WriteNBytes(context^.output, ORD(current_symbol^[1]), @current_symbol^[2]);
|
written_bytes := WriteNBytes(context^.output, ORD(current_symbol^[1]), @current_symbol^[2]);
|
||||||
current_symbol := current_symbol + 1;
|
current_symbol := current_symbol + 1;
|
||||||
|
|
||||||
while ORD(current_symbol^[1]) <> 0 do
|
while ORD(current_symbol^[1]) <> 0 do
|
||||||
WriteString(context^.output, ', ');
|
WriteString(context^.output, ", ");
|
||||||
written_bytes := WriteNBytes(context^.output, ORD(current_symbol^[1]), @current_symbol^[2]);
|
written_bytes := WriteNBytes(context^.output, ORD(current_symbol^[1]), @current_symbol^[2]);
|
||||||
current_symbol := current_symbol + 1;
|
current_symbol := current_symbol + 1;
|
||||||
end;
|
end;
|
||||||
@@ -76,10 +76,10 @@ var
|
|||||||
buffer: [20]CHAR;
|
buffer: [20]CHAR;
|
||||||
written_bytes: Word;
|
written_bytes: Word;
|
||||||
begin
|
begin
|
||||||
WriteString(context^.output, ' ');
|
WriteString(context^.output, " ");
|
||||||
written_bytes := WriteNBytes(context^.output, ORD(declaration^.constant_name[1]), @declaration^.constant_name[2]);
|
written_bytes := WriteNBytes(context^.output, ORD(declaration^.constant_name[1]), @declaration^.constant_name[2]);
|
||||||
|
|
||||||
WriteString(context^.output, ' = ');
|
WriteString(context^.output, " = ");
|
||||||
|
|
||||||
IntToStr(declaration^.constant_value, 0, buffer);
|
IntToStr(declaration^.constant_value, 0, buffer);
|
||||||
WriteString(context^.output, buffer);
|
WriteString(context^.output, buffer);
|
||||||
@@ -92,7 +92,7 @@ var
|
|||||||
current_declaration: ^^AstConstantDeclaration;
|
current_declaration: ^^AstConstantDeclaration;
|
||||||
begin
|
begin
|
||||||
if declarations^ <> nil then
|
if declarations^ <> nil then
|
||||||
WriteString(context^.output, 'CONST');
|
WriteString(context^.output, "CONST");
|
||||||
WriteLine(context^.output);
|
WriteLine(context^.output);
|
||||||
|
|
||||||
current_declaration := declarations;
|
current_declaration := declarations;
|
||||||
@@ -110,9 +110,9 @@ end;
|
|||||||
proc transpile_module(context: ^TranspilerContext, result: ^AstModule);
|
proc transpile_module(context: ^TranspilerContext, result: ^AstModule);
|
||||||
begin
|
begin
|
||||||
if result^.main = false then
|
if result^.main = false then
|
||||||
WriteString(context^.output, 'IMPLEMENTATION ')
|
WriteString(context^.output, "IMPLEMENTATION ")
|
||||||
end;
|
end;
|
||||||
WriteString(context^.output, 'MODULE ');
|
WriteString(context^.output, "MODULE ");
|
||||||
|
|
||||||
(* Write the module name and end the line with a semicolon and newline. *)
|
(* Write the module name and end the line with a semicolon and newline. *)
|
||||||
transpile_module_name(context);
|
transpile_module_name(context);
|
||||||
@@ -129,10 +129,10 @@ begin
|
|||||||
transpile_procedure_part(context, result^.procedures);
|
transpile_procedure_part(context, result^.procedures);
|
||||||
transpile_statement_part(context, result^.statements);
|
transpile_statement_part(context, result^.statements);
|
||||||
|
|
||||||
WriteString(context^.output, 'END ');
|
WriteString(context^.output, "END ");
|
||||||
transpile_module_name(context);
|
transpile_module_name(context);
|
||||||
|
|
||||||
WriteChar(context^.output, '.');
|
WriteChar(context^.output, ".");
|
||||||
WriteLine(context^.output)
|
WriteLine(context^.output)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -144,10 +144,10 @@ begin
|
|||||||
current_field := fields;
|
current_field := fields;
|
||||||
|
|
||||||
while ORD(current_field^.field_name[1]) <> 0 do
|
while ORD(current_field^.field_name[1]) <> 0 do
|
||||||
WriteString(context^.output, ' ');
|
WriteString(context^.output, " ");
|
||||||
written_bytes := WriteNBytes(context^.output, ORD(current_field^.field_name[1]), @current_field^.field_name[2]);
|
written_bytes := WriteNBytes(context^.output, ORD(current_field^.field_name[1]), @current_field^.field_name[2]);
|
||||||
|
|
||||||
WriteString(context^.output, ': ');
|
WriteString(context^.output, ": ");
|
||||||
transpile_type_expression(context, current_field^.field_type);
|
transpile_type_expression(context, current_field^.field_type);
|
||||||
|
|
||||||
current_field := current_field + 1;
|
current_field := current_field + 1;
|
||||||
@@ -161,15 +161,15 @@ end;
|
|||||||
|
|
||||||
proc transpile_record_type(context: ^TranspilerContext, type_expression: ^AstTypeExpression);
|
proc transpile_record_type(context: ^TranspilerContext, type_expression: ^AstTypeExpression);
|
||||||
begin
|
begin
|
||||||
WriteString(context^.output, 'RECORD');
|
WriteString(context^.output, "RECORD");
|
||||||
WriteLine(context^.output);
|
WriteLine(context^.output);
|
||||||
transpile_type_fields(context, type_expression^.fields);
|
transpile_type_fields(context, type_expression^.fields);
|
||||||
WriteString(context^.output, ' END')
|
WriteString(context^.output, " END")
|
||||||
end;
|
end;
|
||||||
|
|
||||||
proc transpile_pointer_type(context: ^TranspilerContext, type_expression: ^AstTypeExpression);
|
proc transpile_pointer_type(context: ^TranspilerContext, type_expression: ^AstTypeExpression);
|
||||||
begin
|
begin
|
||||||
WriteString(context^.output, 'POINTER TO ');
|
WriteString(context^.output, "POINTER TO ");
|
||||||
|
|
||||||
transpile_type_expression(context, type_expression^.target)
|
transpile_type_expression(context, type_expression^.target)
|
||||||
end;
|
end;
|
||||||
@@ -178,17 +178,17 @@ proc transpile_array_type(context: ^TranspilerContext, type_expression: ^AstType
|
|||||||
var
|
var
|
||||||
buffer: [20]CHAR;
|
buffer: [20]CHAR;
|
||||||
begin
|
begin
|
||||||
WriteString(context^.output, 'ARRAY');
|
WriteString(context^.output, "ARRAY");
|
||||||
|
|
||||||
if type_expression^.length <> 0 then
|
if type_expression^.length <> 0 then
|
||||||
WriteString(context^.output, '[1..');
|
WriteString(context^.output, "[1..");
|
||||||
|
|
||||||
IntToStr(type_expression^.length, 0, buffer);
|
IntToStr(type_expression^.length, 0, buffer);
|
||||||
WriteString(context^.output, buffer);
|
WriteString(context^.output, buffer);
|
||||||
|
|
||||||
WriteChar(context^.output, ']')
|
WriteChar(context^.output, ']')
|
||||||
end;
|
end;
|
||||||
WriteString(context^.output, ' OF ');
|
WriteString(context^.output, " OF ");
|
||||||
|
|
||||||
transpile_type_expression(context, type_expression^.base)
|
transpile_type_expression(context, type_expression^.base)
|
||||||
end;
|
end;
|
||||||
@@ -200,22 +200,22 @@ var
|
|||||||
begin
|
begin
|
||||||
current_case := type_expression^.cases;
|
current_case := type_expression^.cases;
|
||||||
|
|
||||||
WriteString(context^.output, '(');
|
WriteString(context^.output, "(");
|
||||||
WriteLine(context^.output);
|
WriteLine(context^.output);
|
||||||
WriteString(context^.output, ' ');
|
WriteString(context^.output, " ");
|
||||||
written_bytes := WriteNBytes(context^.output, ORD(current_case^[1]), @current_case^[2]);
|
written_bytes := WriteNBytes(context^.output, ORD(current_case^[1]), @current_case^[2]);
|
||||||
current_case := current_case + 1;
|
current_case := current_case + 1;
|
||||||
|
|
||||||
while ORD(current_case^[1]) <> 0 do
|
while ORD(current_case^[1]) <> 0 do
|
||||||
WriteChar(context^.output, ',');
|
WriteChar(context^.output, ',');
|
||||||
WriteLine(context^.output);
|
WriteLine(context^.output);
|
||||||
WriteString(context^.output, ' ');
|
WriteString(context^.output, " ");
|
||||||
written_bytes := WriteNBytes(context^.output, ORD(current_case^[1]), @current_case^[2]);
|
written_bytes := WriteNBytes(context^.output, ORD(current_case^[1]), @current_case^[2]);
|
||||||
|
|
||||||
current_case := current_case + 1
|
current_case := current_case + 1
|
||||||
end;
|
end;
|
||||||
WriteLine(context^.output);
|
WriteLine(context^.output);
|
||||||
WriteString(context^.output, ' )')
|
WriteString(context^.output, " )")
|
||||||
end;
|
end;
|
||||||
|
|
||||||
proc transpile_named_type(context: ^TranspilerContext, type_expression: ^AstTypeExpression);
|
proc transpile_named_type(context: ^TranspilerContext, type_expression: ^AstTypeExpression);
|
||||||
@@ -231,7 +231,7 @@ var
|
|||||||
current_parameter: ^^AstTypeExpression;
|
current_parameter: ^^AstTypeExpression;
|
||||||
parameter_count: Word;
|
parameter_count: Word;
|
||||||
begin
|
begin
|
||||||
WriteString(context^.output, 'PROCEDURE(');
|
WriteString(context^.output, "PROCEDURE(");
|
||||||
current_parameter := type_expression^.parameters;
|
current_parameter := type_expression^.parameters;
|
||||||
|
|
||||||
while current_parameter^ <> nil do
|
while current_parameter^ <> nil do
|
||||||
@@ -240,7 +240,7 @@ begin
|
|||||||
current_parameter := current_parameter + 1;
|
current_parameter := current_parameter + 1;
|
||||||
|
|
||||||
if current_parameter^ <> nil then
|
if current_parameter^ <> nil then
|
||||||
WriteString(context^.output, ', ')
|
WriteString(context^.output, ", ")
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
WriteChar(context^.output, ')')
|
WriteChar(context^.output, ')')
|
||||||
@@ -272,10 +272,10 @@ proc transpile_type_declaration(context: ^TranspilerContext, declaration: ^AstTy
|
|||||||
var
|
var
|
||||||
written_bytes: Word;
|
written_bytes: Word;
|
||||||
begin
|
begin
|
||||||
WriteString(context^.output, ' ');
|
WriteString(context^.output, " ");
|
||||||
|
|
||||||
written_bytes := WriteNBytes(context^.output, ORD(declaration^.identifier[1]), @declaration^.identifier[2]);
|
written_bytes := WriteNBytes(context^.output, ORD(declaration^.identifier[1]), @declaration^.identifier[2]);
|
||||||
WriteString(context^.output, ' = ');
|
WriteString(context^.output, " = ");
|
||||||
|
|
||||||
transpile_type_expression(context, declaration^.type_expression);
|
transpile_type_expression(context, declaration^.type_expression);
|
||||||
write_semicolon(context^.output)
|
write_semicolon(context^.output)
|
||||||
@@ -286,7 +286,7 @@ var
|
|||||||
current_declaration: ^^AstTypedDeclaration;
|
current_declaration: ^^AstTypedDeclaration;
|
||||||
begin
|
begin
|
||||||
if declarations^ <> nil then
|
if declarations^ <> nil then
|
||||||
WriteString(context^.output, 'TYPE');
|
WriteString(context^.output, "TYPE");
|
||||||
WriteLine(context^.output);
|
WriteLine(context^.output);
|
||||||
|
|
||||||
current_declaration := declarations;
|
current_declaration := declarations;
|
||||||
@@ -303,10 +303,10 @@ proc transpile_variable_declaration(context: ^TranspilerContext, declaration: ^A
|
|||||||
var
|
var
|
||||||
written_bytes: Word;
|
written_bytes: Word;
|
||||||
begin
|
begin
|
||||||
WriteString(context^.output, ' ');
|
WriteString(context^.output, " ");
|
||||||
written_bytes := WriteNBytes(context^.output, ORD(declaration^.variable_name[1]), @declaration^.variable_name[2]);
|
written_bytes := WriteNBytes(context^.output, ORD(declaration^.variable_name[1]), @declaration^.variable_name[2]);
|
||||||
|
|
||||||
WriteString(context^.output, ': ');
|
WriteString(context^.output, ": ");
|
||||||
|
|
||||||
transpile_type_expression(context, declaration^.variable_type);
|
transpile_type_expression(context, declaration^.variable_type);
|
||||||
write_semicolon(context^.output)
|
write_semicolon(context^.output)
|
||||||
@@ -317,7 +317,7 @@ var
|
|||||||
current_declaration: ^^AstVariableDeclaration;
|
current_declaration: ^^AstVariableDeclaration;
|
||||||
begin
|
begin
|
||||||
if declarations^ <> nil then
|
if declarations^ <> nil then
|
||||||
WriteString(context^.output, 'VAR');
|
WriteString(context^.output, "VAR");
|
||||||
WriteLine(context^.output);
|
WriteLine(context^.output);
|
||||||
|
|
||||||
current_declaration := declarations;
|
current_declaration := declarations;
|
||||||
@@ -338,7 +338,7 @@ var
|
|||||||
parameter_index: Word;
|
parameter_index: Word;
|
||||||
current_parameter: ^AstTypedDeclaration;
|
current_parameter: ^AstTypedDeclaration;
|
||||||
begin
|
begin
|
||||||
WriteString(context^.output, 'PROCEDURE ');
|
WriteString(context^.output, "PROCEDURE ");
|
||||||
written_bytes := WriteNBytes(context^.output, ORD(declaration^.name[1]), @declaration^.name[2]);
|
written_bytes := WriteNBytes(context^.output, ORD(declaration^.name[1]), @declaration^.name[2]);
|
||||||
WriteChar(context^.output, '(');
|
WriteChar(context^.output, '(');
|
||||||
|
|
||||||
@@ -347,22 +347,22 @@ begin
|
|||||||
|
|
||||||
while parameter_index < declaration^.parameter_count do
|
while parameter_index < declaration^.parameter_count do
|
||||||
written_bytes := WriteNBytes(context^.output, ORD(current_parameter^.identifier[1]), @current_parameter^.identifier[2]);
|
written_bytes := WriteNBytes(context^.output, ORD(current_parameter^.identifier[1]), @current_parameter^.identifier[2]);
|
||||||
WriteString(context^.output, ': ');
|
WriteString(context^.output, ": ");
|
||||||
transpile_type_expression(context, current_parameter^.type_expression);
|
transpile_type_expression(context, current_parameter^.type_expression);
|
||||||
|
|
||||||
parameter_index := parameter_index + 1u;
|
parameter_index := parameter_index + 1u;
|
||||||
current_parameter := current_parameter + 1;
|
current_parameter := current_parameter + 1;
|
||||||
|
|
||||||
if parameter_index <> declaration^.parameter_count then
|
if parameter_index <> declaration^.parameter_count then
|
||||||
WriteString(context^.output, '; ')
|
WriteString(context^.output, "; ")
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
WriteString(context^.output, ')');
|
WriteString(context^.output, ")");
|
||||||
|
|
||||||
(* Check for the return type and write it. *)
|
(* Check for the return type and write it. *)
|
||||||
if declaration^.return_type <> nil then
|
if declaration^.return_type <> nil then
|
||||||
WriteString(context^.output, ': ');
|
WriteString(context^.output, ": ");
|
||||||
transpile_type_expression(context, declaration^.return_type)
|
transpile_type_expression(context, declaration^.return_type)
|
||||||
end;
|
end;
|
||||||
write_semicolon(context^.output)
|
write_semicolon(context^.output)
|
||||||
@@ -388,10 +388,10 @@ begin
|
|||||||
| AstBinaryOperator.not_equals: WriteChar(context^.output, '#')
|
| AstBinaryOperator.not_equals: WriteChar(context^.output, '#')
|
||||||
| AstBinaryOperator.less: WriteChar(context^.output, '<')
|
| AstBinaryOperator.less: WriteChar(context^.output, '<')
|
||||||
| AstBinaryOperator.greater: WriteChar(context^.output, '>')
|
| AstBinaryOperator.greater: WriteChar(context^.output, '>')
|
||||||
| AstBinaryOperator.less_equal: WriteString(context^.output, '<=')
|
| AstBinaryOperator.less_equal: WriteString(context^.output, "<=")
|
||||||
| AstBinaryOperator.greater_equal: WriteString(context^.output, '>=')
|
| AstBinaryOperator.greater_equal: WriteString(context^.output, ">=")
|
||||||
| AstBinaryOperator.disjunction: WriteString(context^.output, 'OR')
|
| AstBinaryOperator.disjunction: WriteString(context^.output, "OR")
|
||||||
| AstBinaryOperatorConjunction: WriteString(context^.output, 'AND')
|
| AstBinaryOperatorConjunction: WriteString(context^.output, "AND")
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -414,13 +414,13 @@ begin
|
|||||||
WriteString(context^.output, literal^.string)
|
WriteString(context^.output, literal^.string)
|
||||||
end;
|
end;
|
||||||
if literal^.kind = AstLiteralKind.null then
|
if literal^.kind = AstLiteralKind.null then
|
||||||
WriteString(context^.output, 'NIL')
|
WriteString(context^.output, "NIL")
|
||||||
end;
|
end;
|
||||||
if (literal^.kind = AstLiteralKind.boolean) & literal^.boolean then
|
if (literal^.kind = AstLiteralKind.boolean) & literal^.boolean then
|
||||||
WriteString(context^.output, 'TRUE')
|
WriteString(context^.output, "TRUE")
|
||||||
end;
|
end;
|
||||||
if (literal^.kind = AstLiteralKind.boolean) & (literal^.boolean = false) then
|
if (literal^.kind = AstLiteralKind.boolean) & (literal^.boolean = false) then
|
||||||
WriteString(context^.output, 'FALSE')
|
WriteString(context^.output, "FALSE")
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
if expression^.kind = astExpressionKindIdentifier then
|
if expression^.kind = astExpressionKindIdentifier then
|
||||||
@@ -466,7 +466,7 @@ begin
|
|||||||
current_argument := current_argument + 1;
|
current_argument := current_argument + 1;
|
||||||
|
|
||||||
while argument_index < expression^.argument_count do
|
while argument_index < expression^.argument_count do
|
||||||
WriteString(context^.output, ', ');
|
WriteString(context^.output, ", ");
|
||||||
|
|
||||||
transpile_expression(context, current_argument^);
|
transpile_expression(context, current_argument^);
|
||||||
|
|
||||||
@@ -480,44 +480,44 @@ end;
|
|||||||
|
|
||||||
proc transpile_if_statement(context: ^TranspilerContext, statement: ^AstStatement);
|
proc transpile_if_statement(context: ^TranspilerContext, statement: ^AstStatement);
|
||||||
begin
|
begin
|
||||||
WriteString(context^.output, 'IF ');
|
WriteString(context^.output, "IF ");
|
||||||
transpile_expression(context, statement^.if_condition);
|
transpile_expression(context, statement^.if_condition);
|
||||||
|
|
||||||
WriteString(context^.output, ' THEN');
|
WriteString(context^.output, " THEN");
|
||||||
WriteLine(context^.output);
|
WriteLine(context^.output);
|
||||||
context^.indentation := context^.indentation + 1u;
|
context^.indentation := context^.indentation + 1u;
|
||||||
|
|
||||||
transpile_compound_statement(context, statement^.if_branch);
|
transpile_compound_statement(context, statement^.if_branch);
|
||||||
context^.indentation := context^.indentation - 1u;
|
context^.indentation := context^.indentation - 1u;
|
||||||
indent(context);
|
indent(context);
|
||||||
WriteString(context^.output, 'END')
|
WriteString(context^.output, "END")
|
||||||
end;
|
end;
|
||||||
|
|
||||||
proc transpile_while_statement(context: ^TranspilerContext, statement: ^AstStatement);
|
proc transpile_while_statement(context: ^TranspilerContext, statement: ^AstStatement);
|
||||||
begin
|
begin
|
||||||
WriteString(context^.output, 'WHILE ');
|
WriteString(context^.output, "WHILE ");
|
||||||
transpile_expression(context, statement^.while_condition);
|
transpile_expression(context, statement^.while_condition);
|
||||||
|
|
||||||
WriteString(context^.output, ' DO');
|
WriteString(context^.output, " DO");
|
||||||
WriteLine(context^.output);
|
WriteLine(context^.output);
|
||||||
context^.indentation := context^.indentation + 1u;
|
context^.indentation := context^.indentation + 1u;
|
||||||
|
|
||||||
transpile_compound_statement(context, statement^.while_body);
|
transpile_compound_statement(context, statement^.while_body);
|
||||||
context^.indentation := context^.indentation - 1u;
|
context^.indentation := context^.indentation - 1u;
|
||||||
indent(context);
|
indent(context);
|
||||||
WriteString(context^.output, 'END')
|
WriteString(context^.output, "END")
|
||||||
end;
|
end;
|
||||||
|
|
||||||
proc transpile_assignment_statement(context: ^TranspilerContext, statement: ^AstStatement);
|
proc transpile_assignment_statement(context: ^TranspilerContext, statement: ^AstStatement);
|
||||||
begin
|
begin
|
||||||
transpile_expression(context, statement^.assignee);
|
transpile_expression(context, statement^.assignee);
|
||||||
WriteString(context^.output, ' := ');
|
WriteString(context^.output, " := ");
|
||||||
transpile_expression(context, statement^.assignment)
|
transpile_expression(context, statement^.assignment)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
proc transpile_return_statement(context: ^TranspilerContext, statement: ^AstStatement);
|
proc transpile_return_statement(context: ^TranspilerContext, statement: ^AstStatement);
|
||||||
begin
|
begin
|
||||||
WriteString(context^.output, 'RETURN ');
|
WriteString(context^.output, "RETURN ");
|
||||||
|
|
||||||
transpile_expression(context, statement^.returned)
|
transpile_expression(context, statement^.returned)
|
||||||
end;
|
end;
|
||||||
@@ -567,7 +567,7 @@ end;
|
|||||||
proc transpile_statement_part(context: ^TranspilerContext, compound: AstCompoundStatement);
|
proc transpile_statement_part(context: ^TranspilerContext, compound: AstCompoundStatement);
|
||||||
begin
|
begin
|
||||||
if compound.count > 0 then
|
if compound.count > 0 then
|
||||||
WriteString(context^.output, 'BEGIN');
|
WriteString(context^.output, "BEGIN");
|
||||||
WriteLine(context^.output);
|
WriteLine(context^.output);
|
||||||
|
|
||||||
context^.indentation := context^.indentation + 1u;
|
context^.indentation := context^.indentation + 1u;
|
||||||
@@ -586,7 +586,7 @@ begin
|
|||||||
transpile_variable_part(context, declaration^.variables, false);
|
transpile_variable_part(context, declaration^.variables, false);
|
||||||
transpile_statement_part(context, declaration^.statements);
|
transpile_statement_part(context, declaration^.statements);
|
||||||
|
|
||||||
WriteString(context^.output, 'END ');
|
WriteString(context^.output, "END ");
|
||||||
written_bytes := WriteNBytes(context^.output, ORD(declaration^.name[1]), @declaration^.name[2]);
|
written_bytes := WriteNBytes(context^.output, ORD(declaration^.name[1]), @declaration^.name[2]);
|
||||||
|
|
||||||
write_semicolon(context^.output)
|
write_semicolon(context^.output)
|
||||||
|
6
source/cstdlib.elna
Normal file
6
source/cstdlib.elna
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
(* This Source Code Form is subject to the terms of the Mozilla Public License,
|
||||||
|
v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||||
|
obtain one at https://mozilla.org/MPL/2.0/. *)
|
||||||
|
module;
|
||||||
|
|
||||||
|
end.
|
Reference in New Issue
Block a user