From feddbff2054449889e8a7986520915f5ef272870 Mon Sep 17 00:00:00 2001 From: jackfiled Date: Tue, 30 Apr 2024 15:04:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=BE=93=E5=87=BA=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E9=94=99=E8=AF=AF=20&&=20=E6=9B=B4=E6=96=B0o?= =?UTF-8?q?pen=5Fset=20(#70)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.rrricardo.top/PostGuard/Canon/pulls/70 --- .../Extensions/RootCommandExtensions.cs | 2 + Canon.Console/Services/Compiler.cs | 11 ++-- open_set/16_mod.pas | 2 +- open_set/46_full_conn.pas | 2 +- open_set/55_long_array2.pas | 22 +++---- open_set/57_many_params.pas | 64 +++++++++---------- open_set/64_nested_loops.pas | 6 +- open_set/65_float.pas | 20 +++--- 8 files changed, 66 insertions(+), 63 deletions(-) diff --git a/Canon.Console/Extensions/RootCommandExtensions.cs b/Canon.Console/Extensions/RootCommandExtensions.cs index 1017886..20ac288 100644 --- a/Canon.Console/Extensions/RootCommandExtensions.cs +++ b/Canon.Console/Extensions/RootCommandExtensions.cs @@ -4,6 +4,7 @@ using Canon.Console.Services; using Canon.Core.Abstractions; using Canon.Core.GrammarParser; using Canon.Core.LexicalParser; +using Canon.Core.SemanticParser; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; @@ -39,6 +40,7 @@ public static class RootCommandExtensions builder.Services.AddSingleton( _ => new CompilerOption { SourceFilename = sourceFilename }); builder.Services.AddTransient(); + builder.Services.AddSingleton(); builder.Services.AddSingleton(_ => GeneratedGrammarParser.Instance); builder.Services.AddHostedService(); diff --git a/Canon.Console/Services/Compiler.cs b/Canon.Console/Services/Compiler.cs index 594f43d..2c3138e 100644 --- a/Canon.Console/Services/Compiler.cs +++ b/Canon.Console/Services/Compiler.cs @@ -1,7 +1,7 @@ using Canon.Console.Models; using Canon.Core.Abstractions; -using Canon.Core.CodeGenerators; using Canon.Core.LexicalParser; +using Canon.Core.SemanticParser; using Canon.Core.SyntaxNodes; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; @@ -12,6 +12,7 @@ public class Compiler( CompilerOption compilerOption, ILexer lexer, IGrammarParser grammarParser, + SyntaxTreeTraveller traveller, IHostApplicationLifetime applicationLifetime, ILogger logger) : IHostedService { @@ -20,10 +21,10 @@ public class Compiler( IEnumerable tokens = lexer.Tokenize(await CreateSourceReader()); ProgramStruct root = grammarParser.Analyse(tokens); - CCodeBuilder builder = new(); - root.GenerateCCode(builder); + CCodeGenerateVisitor visitor = new(); + traveller.Travel(root, visitor); - await WriteToOutputFile(builder.Build()); + await WriteToOutputFile(visitor.Builder.Build()); applicationLifetime.StopApplication(); } @@ -49,7 +50,7 @@ public class Compiler( private async Task WriteToOutputFile(string compiledCode) { - FileInfo outputFile = new(Path.Combine(Environment.CurrentDirectory, + FileInfo outputFile = new(Path.Combine(Path.GetDirectoryName(compilerOption.SourceFilename)!, Path.GetFileNameWithoutExtension(compilerOption.SourceFilename) + ".c")); logger.LogDebug("Select output file: '{}'.", outputFile.Name); diff --git a/open_set/16_mod.pas b/open_set/16_mod.pas index 9e8f5af..951c18c 100644 --- a/open_set/16_mod.pas +++ b/open_set/16_mod.pas @@ -3,5 +3,5 @@ var a: integer; begin a := 10; - write(a / 3); + write(a div 3); end. diff --git a/open_set/46_full_conn.pas b/open_set/46_full_conn.pas index 8de511e..e4f228d 100644 --- a/open_set/46_full_conn.pas +++ b/open_set/46_full_conn.pas @@ -13,7 +13,7 @@ end; function model: integer; begin - if (+relu_reg(+a[0][0] * 85 + a[0][1] * 23 + a[0][2] * -82 + a[0][3] * -103 + a[0][4] * -123 + a[1][0] * 64 + a[1][1] * -120 + a[1][2] * 50 + a[1][3] * -59 + a[1][4] * 47 + a[2][0] * -111 + a[2][1] * -67 + a[2][2] * -106 + a[2][3] * -75 + a[2][4] * -102 + a[3][0] * 34 + a[3][1] * -39 + a[3][2] * 65 + a[3][3] * 47 + a[3][4] * 113 + a[4][0] * 110 + a[4][1] * 47 + a[4][2] * -4 + a[4][3] * 80 + a[4][4] * 46) * 39 + relu_reg(+a[0][0] * -106 + a[0][1] * 126 + a[0][2] * -18 + a[0][3] * -31 + a[0][4] * -8 + a[1][0] * 47 + a[1][1] * -4 + a[1][2] * 67 + a[1][3] * -94 + a[1][4] * -121 + a[2][0] * 7 + a[2][1] * -21 + a[2][2] * -60 + a[2][3] * -43 + a[2][4] * 105 + a[3][0] * -42 + a[3][1] * 87 + a[3][2] * 29 + a[3][3] * -106 + a[3][4] * -31 + a[4][0] * -110 + a[4][1] * -100 + a[4][2] * -22 + a[4][3] * -75 + a[4][4] * -125) * 77 + relu_reg(+a[0][0] * 26 + a[0][1] * 76 + a[0][2] * -70 + a[0][3] * 29 + a[0][4] * -95 + a[1][0] * 96 + a[1][1] * 52 + a[1][2] * -68 + a[1][3] * -5 + a[1][4] * 34 + a[2][0] * -34 + a[2][1] * 102 + a[2][2] * 6 + a[2][3] * -38 + a[2][4] * 27 + a[3][0] * 110 + a[3][1] * 116 + a[3][2] * 39 + a[3][3] * -63 + a[3][4] * -99 + a[4][0] * 65 + a[4][1] * 120 + a[4][2] * -39 + a[4][3] * -6 + a[4][4] * 94) * 127 + relu_reg(+a[0][0] * -23 + a[0][1] * -63 + a[0][2] * 49 + a[0][3] * 50 + a[0][4] * 72 + a[1][0] * 85 + a[1][1] * -30 + a[1][2] * 12 + a[1][3] * 125 + a[1][4] * -117 + a[2][0] * -65 + a[2][1] * -67 + a[2][2] * 125 + a[2][3] * 110 + a[2][4] * -31 + a[3][0] * -123 + a[3][1] * 83 + a[3][2] * 122 + a[3][3] * 11 + a[3][4] * -23 + a[4][0] * -47 + a[4][1] * -32 + a[4][2] * -117 + a[4][3] * 95 + a[4][4] * 118) * -106 + relu_reg(+a[0][0] * 8 + a[0][1] * 82 + a[0][2] * -104 + a[0][3] * 101 + a[0][4] * -116 + a[1][0] * -63 + a[1][1] * -16 + a[1][2] * -70 + a[1][3] * 125 + a[1][4] * 75 + a[2][0] * 66 + a[2][1] * -96 + a[2][2] * -101 + a[2][3] * -114 + a[2][4] * 59 + a[3][0] * 12 + a[3][1] * 5 + a[3][2] * -95 + a[3][3] * 116 + a[3][4] * -93 + a[4][0] * 15 + a[4][1] * 79 + a[4][2] * 3 + a[4][3] * 49 + a[4][4] * -124) * -3 + relu_reg(+a[0][0] * 81 + a[0][1] * 68 + a[0][2] * -102 + a[0][3] * -74 + a[0][4] * 121 + a[1][0] * -15 + a[1][1] * 55 + a[1][2] * 101 + a[1][3] * -13 + a[1][4] * -62 + a[2][0] * 64 + a[2][1] * 114 + a[2][2] * 38 + a[2][3] * -21 + a[2][4] * 112 + a[3][0] * 114 + a[3][1] * 112 + a[3][2] * -10 + a[3][3] * -16 + a[3][4] * -50 + a[4][0] * -112 + a[4][1] * -116 + a[4][2] * -54 + a[4][3] * 82 + a[4][4] * -72) * 32 + relu_reg(+a[0][0] * 15 + a[0][1] * -77 + a[0][2] * 66 + a[0][3] * -90 + a[0][4] * -6 + a[1][0] * -30 + a[1][1] * -8 + a[1][2] * 81 + a[1][3] * 2 + a[1][4] * -110 + a[2][0] * -95 + a[2][1] * 59 + a[2][2] * 52 + a[2][3] * 15 + a[2][4] * 55 + a[3][0] * -33 + a[3][1] * 14 + a[3][2] * 58 + a[3][3] * 67 + a[3][4] * 86 + a[4][0] * -79 + a[4][1] * 48 + a[4][2] * -13 + a[4][3] * -15 + a[4][4] * 66) * -95 + relu_reg(+a[0][0] * 33 + a[0][1] * 82 + a[0][2] * 67 + a[0][3] * 30 + a[0][4] * -2 + a[1][0] * 65 + a[1][1] * 120 + a[1][2] * -13 + a[1][3] * 18 + a[1][4] * 5 + a[2][0] * 104 + a[2][1] * -119 + a[2][2] * -7 + a[2][3] * 71 + a[2][4] * 107 + a[3][0] * 24 + a[3][1] * 82 + a[3][2] * -96 + a[3][3] * -104 + a[3][4] * -121 + a[4][0] * 65 + a[4][1] * 97 + a[4][2] * 83 + a[4][3] * 46 + a[4][4] * -84) * -50 + relu_reg(+a[0][0] * -29 + a[0][1] * 7 + a[0][2] * -70 + a[0][3] * 38 + a[0][4] * -90 + a[1][0] * -15 + a[1][1] * -32 + a[1][2] * 37 + a[1][3] * 36 + a[1][4] * -62 + a[2][0] * -125 + a[2][1] * -46 + a[2][2] * -70 + a[2][3] * 37 + a[2][4] * -73 + a[3][0] * -34 + a[3][1] * -87 + a[3][2] * -75 + a[3][3] * 71 + a[3][4] * -77 + a[4][0] * 53 + a[4][1] * 37 + a[4][2] * -103 + a[4][3] * -13 + a[4][4] * -114) * -23 + relu_reg(+a[0][0] * 67 + a[0][1] * 42 + a[0][2] * 41 + a[0][3] * -123 + a[0][4] * -92 + a[1][0] * 10 + a[1][1] * -77 + a[1][2] * 75 + a[1][3] * 96 + a[1][4] * -51 + a[2][0] * 109 + a[2][1] * -74 + a[2][2] * -7 + a[2][3] * -122 + a[2][4] * 67 + a[3][0] * 47 + a[3][1] * 22 + a[3][2] * -68 + a[3][3] * 38 + a[3][4] * 29 + a[4][0] * 115 + a[4][1] * -121 + a[4][2] * 36 + a[4][3] * -49 + a[4][4] * 85) * 46 > 0) then + if (+relu_reg(+a[0, 0] * 85 + a[0, 1] * 23 + a[0, 2] * -82 + a[0, 3] * -103 + a[0, 4] * -123 + a[1, 0] * 64 + a[1, 1] * -120 + a[1, 2] * 50 + a[1, 3] * -59 + a[1, 4] * 47 + a[2, 0] * -111 + a[2, 1] * -67 + a[2, 2] * -106 + a[2, 3] * -75 + a[2, 4] * -102 + a[3, 0] * 34 + a[3, 1] * -39 + a[3, 2] * 65 + a[3, 3] * 47 + a[3, 4] * 113 + a[4, 0] * 110 + a[4, 1] * 47 + a[4, 2] * -4 + a[4, 3] * 80 + a[4, 4] * 46) * 39 + relu_reg(+a[0, 0] * -106 + a[0, 1] * 126 + a[0, 2] * -18 + a[0, 3] * -31 + a[0, 4] * -8 + a[1, 0] * 47 + a[1, 1] * -4 + a[1, 2] * 67 + a[1, 3] * -94 + a[1, 4] * -121 + a[2, 0] * 7 + a[2, 1] * -21 + a[2, 2] * -60 + a[2, 3] * -43 + a[2, 4] * 105 + a[3, 0] * -42 + a[3, 1] * 87 + a[3, 2] * 29 + a[3, 3] * -106 + a[3, 4] * -31 + a[4, 0] * -110 + a[4, 1] * -100 + a[4, 2] * -22 + a[4, 3] * -75 + a[4, 4] * -125) * 77 + relu_reg(+a[0, 0] * 26 + a[0, 1] * 76 + a[0, 2] * -70 + a[0, 3] * 29 + a[0, 4] * -95 + a[1, 0] * 96 + a[1, 1] * 52 + a[1, 2] * -68 + a[1, 3] * -5 + a[1, 4] * 34 + a[2, 0] * -34 + a[2, 1] * 102 + a[2, 2] * 6 + a[2, 3] * -38 + a[2, 4] * 27 + a[3, 0] * 110 + a[3, 1] * 116 + a[3, 2] * 39 + a[3, 3] * -63 + a[3, 4] * -99 + a[4, 0] * 65 + a[4, 1] * 120 + a[4, 2] * -39 + a[4, 3] * -6 + a[4, 4] * 94) * 127 + relu_reg(+a[0, 0] * -23 + a[0, 1] * -63 + a[0, 2] * 49 + a[0, 3] * 50 + a[0, 4] * 72 + a[1, 0] * 85 + a[1, 1] * -30 + a[1, 2] * 12 + a[1, 3] * 125 + a[1, 4] * -117 + a[2, 0] * -65 + a[2, 1] * -67 + a[2, 2] * 125 + a[2, 3] * 110 + a[2, 4] * -31 + a[3, 0] * -123 + a[3, 1] * 83 + a[3, 2] * 122 + a[3, 3] * 11 + a[3, 4] * -23 + a[4, 0] * -47 + a[4, 1] * -32 + a[4, 2] * -117 + a[4, 3] * 95 + a[4, 4] * 118) * -106 + relu_reg(+a[0, 0] * 8 + a[0, 1] * 82 + a[0, 2] * -104 + a[0, 3] * 101 + a[0, 4] * -116 + a[1, 0] * -63 + a[1, 1] * -16 + a[1, 2] * -70 + a[1, 3] * 125 + a[1, 4] * 75 + a[2, 0] * 66 + a[2, 1] * -96 + a[2, 2] * -101 + a[2, 3] * -114 + a[2, 4] * 59 + a[3, 0] * 12 + a[3, 1] * 5 + a[3, 2] * -95 + a[3, 3] * 116 + a[3, 4] * -93 + a[4, 0] * 15 + a[4, 1] * 79 + a[4, 2] * 3 + a[4, 3] * 49 + a[4, 4] * -124) * -3 + relu_reg(+a[0, 0] * 81 + a[0, 1] * 68 + a[0, 2] * -102 + a[0, 3] * -74 + a[0, 4] * 121 + a[1, 0] * -15 + a[1, 1] * 55 + a[1, 2] * 101 + a[1, 3] * -13 + a[1, 4] * -62 + a[2, 0] * 64 + a[2, 1] * 114 + a[2, 2] * 38 + a[2, 3] * -21 + a[2, 4] * 112 + a[3, 0] * 114 + a[3, 1] * 112 + a[3, 2] * -10 + a[3, 3] * -16 + a[3, 4] * -50 + a[4, 0] * -112 + a[4, 1] * -116 + a[4, 2] * -54 + a[4, 3] * 82 + a[4, 4] * -72) * 32 + relu_reg(+a[0, 0] * 15 + a[0, 1] * -77 + a[0, 2] * 66 + a[0, 3] * -90 + a[0, 4] * -6 + a[1, 0] * -30 + a[1, 1] * -8 + a[1, 2] * 81 + a[1, 3] * 2 + a[1, 4] * -110 + a[2, 0] * -95 + a[2, 1] * 59 + a[2, 2] * 52 + a[2, 3] * 15 + a[2, 4] * 55 + a[3, 0] * -33 + a[3, 1] * 14 + a[3, 2] * 58 + a[3, 3] * 67 + a[3, 4] * 86 + a[4, 0] * -79 + a[4, 1] * 48 + a[4, 2] * -13 + a[4, 3] * -15 + a[4, 4] * 66) * -95 + relu_reg(+a[0, 0] * 33 + a[0, 1] * 82 + a[0, 2] * 67 + a[0, 3] * 30 + a[0, 4] * -2 + a[1, 0] * 65 + a[1, 1] * 120 + a[1, 2] * -13 + a[1, 3] * 18 + a[1, 4] * 5 + a[2, 0] * 104 + a[2, 1] * -119 + a[2, 2] * -7 + a[2, 3] * 71 + a[2, 4] * 107 + a[3, 0] * 24 + a[3, 1] * 82 + a[3, 2] * -96 + a[3, 3] * -104 + a[3, 4] * -121 + a[4, 0] * 65 + a[4, 1] * 97 + a[4, 2] * 83 + a[4, 3] * 46 + a[4, 4] * -84) * -50 + relu_reg(+a[0, 0] * -29 + a[0, 1] * 7 + a[0, 2] * -70 + a[0, 3] * 38 + a[0, 4] * -90 + a[1, 0] * -15 + a[1, 1] * -32 + a[1, 2] * 37 + a[1, 3] * 36 + a[1, 4] * -62 + a[2, 0] * -125 + a[2, 1] * -46 + a[2, 2] * -70 + a[2, 3] * 37 + a[2, 4] * -73 + a[3, 0] * -34 + a[3, 1] * -87 + a[3, 2] * -75 + a[3, 3] * 71 + a[3, 4] * -77 + a[4, 0] * 53 + a[4, 1] * 37 + a[4, 2] * -103 + a[4, 3] * -13 + a[4, 4] * -114) * -23 + relu_reg(+a[0, 0] * 67 + a[0, 1] * 42 + a[0, 2] * 41 + a[0, 3] * -123 + a[0, 4] * -92 + a[1, 0] * 10 + a[1, 1] * -77 + a[1, 2] * 75 + a[1, 3] * 96 + a[1, 4] * -51 + a[2, 0] * 109 + a[2, 1] * -74 + a[2, 2] * -7 + a[2, 3] * -122 + a[2, 4] * 67 + a[3, 0] * 47 + a[3, 1] * 22 + a[3, 2] * -68 + a[3, 3] * 38 + a[3, 4] * 29 + a[4, 0] * 115 + a[4, 1] * -121 + a[4, 2] * 36 + a[4, 3] * -49 + a[4, 4] * 85) * 46 > 0) then model := 1 else model := 0; diff --git a/open_set/55_long_array2.pas b/open_set/55_long_array2.pas index 88cc7a8..3d9b3bc 100644 --- a/open_set/55_long_array2.pas +++ b/open_set/55_long_array2.pas @@ -15,16 +15,16 @@ begin end; begin - b[1][0] := 1; - b[2][0] := 2; - b[2][1] := 3; - b[3][0] := 4; - b[3][1] := 5; - b[3][2] := 6; - c[0][0] := 1; - c[0][1] := 2; - c[1][0] := 3; - c[1][1] := 4; + b[1, 0] := 1; + b[2, 0] := 2; + b[2, 1] := 3; + b[3, 0] := 4; + b[3, 1] := 5; + b[3, 2] := 6; + c[0, 0] := 1; + c[0, 1] := 2; + c[1, 0] := 3; + c[1, 1] := 4; write(f1); - write(c[2][0]); + write(c[2, 0]); end. diff --git a/open_set/57_many_params.pas b/open_set/57_many_params.pas index c78c2fb..2e2fe03 100644 --- a/open_set/57_many_params.pas +++ b/open_set/57_many_params.pas @@ -19,38 +19,38 @@ end; function param32_arr: integer; var sum: integer; begin - sum := arr[0][0] + arr[0][1]; - sum := sum + arr[1][0] + arr[1][1]; - sum := sum + arr[2][0] + arr[2][1]; - sum := sum + arr[3][0] + arr[3][1]; - sum := sum + arr[4][0] + arr[4][1]; - sum := sum + arr[5][0] + arr[5][1]; - sum := sum + arr[6][0] + arr[6][1]; - sum := sum + arr[7][0] + arr[7][1]; - sum := sum + arr[8][0] + arr[8][1]; - sum := sum + arr[9][0] + arr[9][1]; - sum := sum + arr[10][0] + arr[10][1]; - sum := sum + arr[11][0] + arr[11][1]; - sum := sum + arr[12][0] + arr[12][1]; - sum := sum + arr[13][0] + arr[13][1]; - sum := sum + arr[14][0] + arr[14][1]; - sum := sum + arr[15][0] + arr[15][1]; - sum := sum + arr[16][0] + arr[16][1]; - sum := sum + arr[17][0] + arr[17][1]; - sum := sum + arr[18][0] + arr[18][1]; - sum := sum + arr[19][0] + arr[19][1]; - sum := sum + arr[20][0] + arr[20][1]; - sum := sum + arr[21][0] + arr[21][1]; - sum := sum + arr[22][0] + arr[22][1]; - sum := sum + arr[23][0] + arr[23][1]; - sum := sum + arr[24][0] + arr[24][1]; - sum := sum + arr[25][0] + arr[25][1]; - sum := sum + arr[26][0] + arr[26][1]; - sum := sum + arr[27][0] + arr[27][1]; - sum := sum + arr[28][0] + arr[28][1]; - sum := sum + arr[29][0] + arr[29][1]; - sum := sum + arr[30][0] + arr[30][1]; - sum := sum + arr[31][0] + arr[31][1]; + sum := arr[0, 0] + arr[0, 1]; + sum := sum + arr[1, 0] + arr[1, 1]; + sum := sum + arr[2, 0] + arr[2, 1]; + sum := sum + arr[3, 0] + arr[3, 1]; + sum := sum + arr[4, 0] + arr[4, 1]; + sum := sum + arr[5, 0] + arr[5, 1]; + sum := sum + arr[6, 0] + arr[6, 1]; + sum := sum + arr[7, 0] + arr[7, 1]; + sum := sum + arr[8, 0] + arr[8, 1]; + sum := sum + arr[9, 0] + arr[9, 1]; + sum := sum + arr[10, 0] + arr[10, 1]; + sum := sum + arr[11, 0] + arr[11, 1]; + sum := sum + arr[12, 0] + arr[12, 1]; + sum := sum + arr[13, 0] + arr[13, 1]; + sum := sum + arr[14, 0] + arr[14, 1]; + sum := sum + arr[15, 0] + arr[15, 1]; + sum := sum + arr[16, 0] + arr[16, 1]; + sum := sum + arr[17, 0] + arr[17, 1]; + sum := sum + arr[18, 0] + arr[18, 1]; + sum := sum + arr[19, 0] + arr[19, 1]; + sum := sum + arr[20, 0] + arr[20, 1]; + sum := sum + arr[21, 0] + arr[21, 1]; + sum := sum + arr[22, 0] + arr[22, 1]; + sum := sum + arr[23, 0] + arr[23, 1]; + sum := sum + arr[24, 0] + arr[24, 1]; + sum := sum + arr[25, 0] + arr[25, 1]; + sum := sum + arr[26, 0] + arr[26, 1]; + sum := sum + arr[27, 0] + arr[27, 1]; + sum := sum + arr[28, 0] + arr[28, 1]; + sum := sum + arr[29, 0] + arr[29, 1]; + sum := sum + arr[30, 0] + arr[30, 1]; + sum := sum + arr[31, 0] + arr[31, 1]; param32_arr := sum; end; diff --git a/open_set/64_nested_loops.pas b/open_set/64_nested_loops.pas index 4330853..a122cfe 100644 --- a/open_set/64_nested_loops.pas +++ b/open_set/64_nested_loops.pas @@ -22,7 +22,7 @@ for a := 0 to x-1 do begin for g := 0 to 1 do begin - arr1[a][b][c][d][e][f][g] := a + b + c + d + e + f + g + x + y; + arr1[a, b, c, d, e, f, g] := a + b + c + d + e + f + g + x + y; end; end; end; @@ -50,7 +50,7 @@ for a := 0 to 9 do begin for g := 0 to 6 do begin - arr2[a][b][c][d][e][f][g] := a + b + d + g; + arr2[a, b, c, d, e, f, g] := a + b + d + g; end; end; end; @@ -78,7 +78,7 @@ ans := 0; begin for g := 0 to n-1 do begin - ans := (ans mod 817) + arr1[a][b][c][d][e][f][g] + arr2[a][b][c][d][e][f][g]; + ans := (ans mod 817) + arr1[a, b, c, d, e, f, g] + arr2[a, b, c, d, e, f, g]; end; end; end; diff --git a/open_set/65_float.pas b/open_set/65_float.pas index d324c14..28b7c6d 100644 --- a/open_set/65_float.pas +++ b/open_set/65_float.pas @@ -21,7 +21,7 @@ end; function circle_area(radius: integer):real; begin - circle_area := PI * radius *radius + (radius * radius) * PI / 2; + circle_area := (PI * radius *radius + (radius * radius) * PI) / 2; end; function float_eq(a,b: real):integer; @@ -32,12 +32,12 @@ begin float_eq := 0 end; -procedure error; +procedure error(); begin write(e); end; -procedure ok; +procedure ok(); begin write(o); end; @@ -45,27 +45,27 @@ end; procedure assert(cond: integer); begin if cond = 0 then - error + error() else - ok; + ok(); end; begin assert(float_eq(circle_area(5), circle_area(FIVE))); if 1.5 <> 0.0 then - ok; + ok(); if (not (3.3 = 0.0)) then - ok; + ok(); if (0.0 <> 0.0) and (3 <> 0.0) then - error; + error(); if (0 <> 0.0) or (0.3 <> 0.0) then - ok; + ok(); p := 0; arr[0] := 1.0; arr[1] := 2.0; input := 0.520; - area := PI * input; + area := PI * input * input; area_trunc := circle_area(0); arr[p] := arr[p] + input;