From d110fb0ac8fbc4375490801060c4b248e96b3653 Mon Sep 17 00:00:00 2001 From: antranigv Date: Fri, 9 Jun 2017 13:10:12 +0400 Subject: [PATCH] changed tabs with spaces --- arrays/Arrays.Mod | 60 ++++++++++++------------ case/Case.Mod | 12 ++--- constants/Constants.Mod | 12 ++--- for/For.Mod | 20 ++++---- hello-world/Console/Hello.Mod | 4 +- hello-world/Out/Hello.Mod | 2 +- ifelse/IfElse.Mod | 57 ++++++++++++---------- procedures/function-procedure/Square.Mod | 11 +++-- procedures/procedure/Procedure.Mod | 5 +- procedures/var-parameter/VarParam.Mod | 20 ++++---- value-types/Values.Mod | 8 ++-- variables/Variables.Mod | 40 ++++++++-------- 12 files changed, 132 insertions(+), 119 deletions(-) diff --git a/arrays/Arrays.Mod b/arrays/Arrays.Mod index 1ccde7d..50ef185 100644 --- a/arrays/Arrays.Mod +++ b/arrays/Arrays.Mod @@ -3,40 +3,40 @@ MODULE arrays; IMPORT Out; VAR - tmp : INTEGER; - matrix : ARRAY 3 OF ARRAY 3 OF INTEGER; - i, v, k : INTEGER; + tmp : INTEGER; + matrix : ARRAY 3 OF ARRAY 3 OF INTEGER; + i, v, k : INTEGER; BEGIN - v := 1; - FOR i := 0 TO LEN(matrix) - 1 DO - FOR k := 0 TO LEN(matrix[i]) - 1 DO - matrix[i][k] := v; - INC(v); - END; - END; + v := 1; + FOR i := 0 TO LEN(matrix) - 1 DO + FOR k := 0 TO LEN(matrix[i]) - 1 DO + matrix[i][k] := v; + INC(v); + END; + END; - FOR i := 0 TO LEN(matrix) - 1 DO - FOR k := 0 TO LEN(matrix[i]) - 1 DO - Out.Int(matrix[i][k], 0); Out.String(" "); - END; - Out.Ln; - END; + FOR i := 0 TO LEN(matrix) - 1 DO + FOR k := 0 TO LEN(matrix[i]) - 1 DO + Out.Int(matrix[i][k], 0); Out.String(" "); + END; + Out.Ln; + END; - FOR i := 0 TO LEN(matrix) - 1 DO - FOR k := i + 1 TO LEN(matrix[i]) - 1 DO - tmp := matrix[i][k]; - matrix[i][k] := matrix[k][i]; - matrix[k][i] := tmp; - END; - END; + FOR i := 0 TO LEN(matrix) - 1 DO + FOR k := i + 1 TO LEN(matrix[i]) - 1 DO + tmp := matrix[i][k]; + matrix[i][k] := matrix[k][i]; + matrix[k][i] := tmp; + END; + END; - Out.Ln; Out.Ln; + Out.Ln; Out.Ln; - FOR i := 0 TO LEN(matrix) - 1 DO - FOR k := 0 TO LEN(matrix[i]) - 1 DO - Out.Int(matrix[i][k], 0); Out.String(" "); - END; - Out.Ln; - END; + FOR i := 0 TO LEN(matrix) - 1 DO + FOR k := 0 TO LEN(matrix[i]) - 1 DO + Out.Int(matrix[i][k], 0); Out.String(" "); + END; + Out.Ln; + END; END arrays. diff --git a/case/Case.Mod b/case/Case.Mod index 2f6fb31..ab6ad5b 100644 --- a/case/Case.Mod +++ b/case/Case.Mod @@ -5,10 +5,10 @@ IMPORT Out, Modules; BEGIN - CASE Modules.ArgCount - 1 OF - 0 : Out.String("There are no arguments"); - | 1 : Out.String("There is one argument"); - | 2 : Out.String("There are two arguments"); - ELSE Out.String("There are more than two arguments") END; - Out.Ln; + CASE Modules.ArgCount - 1 OF + 0 : Out.String("There are no arguments"); + | 1 : Out.String("There is one argument"); + | 2 : Out.String("There are two arguments"); + ELSE Out.String("There are more than two arguments") END; + Out.Ln; END case. diff --git a/constants/Constants.Mod b/constants/Constants.Mod index 74ad7c4..47dc4c4 100644 --- a/constants/Constants.Mod +++ b/constants/Constants.Mod @@ -3,12 +3,12 @@ MODULE constants; IMPORT Out; CONST - s = "if it moves, compile it!"; - n = 42; - m = n * 2; + s = "if it moves, compile it!"; + n = 42; + m = n * 2; BEGIN - Out.String(s); Out.Ln; - Out.Int(n, 0); Out.Ln; - Out.Int(m, 0); Out.Ln; + Out.String(s); Out.Ln; + Out.Int(n, 0); Out.Ln; + Out.Int(m, 0); Out.Ln; END constants. diff --git a/for/For.Mod b/for/For.Mod index 9fd8ba5..8e110bd 100644 --- a/for/For.Mod +++ b/for/For.Mod @@ -3,17 +3,17 @@ MODULE for; IMPORT Out; VAR - i : INTEGER; + i : INTEGER; BEGIN - Out.String("i is "); Out.Int(i, 0); Out.Ln; - Out.String("For loop started"); Out.Ln; - FOR i := 0 TO 10 DO - Out.String("i : "); Out.Int(i, 0); Out.Ln; - END; - Out.String("For-By loop started"); Out.Ln; - FOR i := 0 TO 10 BY 2 DO - Out.String("i : "); Out.Int(i, 0); Out.Ln; - END; + Out.String("i is "); Out.Int(i, 0); Out.Ln; + Out.String("For loop started"); Out.Ln; + FOR i := 0 TO 10 DO + Out.String("i : "); Out.Int(i, 0); Out.Ln; + END; + Out.String("For-By loop started"); Out.Ln; + FOR i := 0 TO 10 BY 2 DO + Out.String("i : "); Out.Int(i, 0); Out.Ln; + END; END for. diff --git a/hello-world/Console/Hello.Mod b/hello-world/Console/Hello.Mod index 4d52e15..479a6ea 100644 --- a/hello-world/Console/Hello.Mod +++ b/hello-world/Console/Hello.Mod @@ -5,6 +5,6 @@ IMPORT Console; BEGIN - Console.String("Hello World!"); - Console.Ln + Console.String("Hello World!"); + Console.Ln END hello. diff --git a/hello-world/Out/Hello.Mod b/hello-world/Out/Hello.Mod index 8532f42..80346a2 100644 --- a/hello-world/Out/Hello.Mod +++ b/hello-world/Out/Hello.Mod @@ -5,5 +5,5 @@ IMPORT Out; BEGIN - Out.String("Hello, World"); Out.Ln + Out.String("Hello, World"); Out.Ln END hello. diff --git a/ifelse/IfElse.Mod b/ifelse/IfElse.Mod index 48bc26b..81ca1d7 100644 --- a/ifelse/IfElse.Mod +++ b/ifelse/IfElse.Mod @@ -7,36 +7,43 @@ VAR n, m : INTEGER; BEGIN - n := 8; m := 4; + n := 8; m := 4; - IF n MOD m = 0 THEN - Out.Int(n,0); Out.String(" is divisible by "); Out.Int(m,0); Out.Ln; - END; + IF n MOD m = 0 THEN + Out.Int(n,0); Out.String(" is divisible by "); Out.Int(m,0); Out.Ln; + END; - n := 7; m := 6; + n := 7; m := 6; - IF n * m = 42 THEN - Out.Int(n,0); Out.String(" times "); Out.Int(m,0); Out.String(" equals 42"); Out.Ln; - END; + IF n * m = 42 THEN + Out.Int(n,0); Out.String(" times "); Out.Int(m,0); Out.String(" equals 42"); Out.Ln; + END; - IF n # m THEN Out.Int(n,0); Out.String(" does not equal "); Out.Int(m,0); Out.Ln; END; + IF n # m THEN Out.Int(n,0); Out.String(" does not equal "); Out.Int(m,0); Out.Ln; END; - IF ODD(n) - THEN - Out.Int(n,0); Out.String(" is odd"); Out.Ln; - ELSE - Out.Int(n,0); Out.String(" is even"); Out.Ln; - END; + IF ODD(n) + THEN + Out.Int(n,0); Out.String(" is odd"); Out.Ln; + ELSE + Out.Int(n,0); Out.String(" is even"); Out.Ln; + END; - n := 9; + IF ~ODD(m) + THEN + Out.Int(m,0); Out.String(" is even"); Out.Ln; + ELSE + Out.Int(m,0); Out.String(" is odd"); Out.Ln; + END; - IF n < 0 - THEN - Out.Int(n, 0); Out.String(" is negative"); Out.Ln; - ELSIF n < 10 - THEN - Out.Int(n, 0); Out.String(" has 1 digit"); Out.Ln; - ELSE - Out.Int(n, 0); Out.String(" has multiple digits"); Out.Ln; - END; + n := 9; + + IF n < 0 + THEN + Out.Int(n, 0); Out.String(" is negative"); Out.Ln; + ELSIF n < 10 + THEN + Out.Int(n, 0); Out.String(" has 1 digit"); Out.Ln; + ELSE + Out.Int(n, 0); Out.String(" has multiple digits"); Out.Ln; + END; END ifelse. diff --git a/procedures/function-procedure/Square.Mod b/procedures/function-procedure/Square.Mod index 03172bd..f972edf 100644 --- a/procedures/function-procedure/Square.Mod +++ b/procedures/function-procedure/Square.Mod @@ -3,15 +3,18 @@ MODULE square; IMPORT Out; + VAR s : INTEGER; + PROCEDURE squared(x : INTEGER): INTEGER; BEGIN - RETURN x * x + RETURN x * x END squared; + BEGIN - s := squared(7); - Out.Int(s, 0); Out.Ln; - Out.Int(squared(8), 0); Out.Ln; + s := squared(7); + Out.Int(s, 0); Out.Ln; + Out.Int(squared(8), 0); Out.Ln; END square. diff --git a/procedures/procedure/Procedure.Mod b/procedures/procedure/Procedure.Mod index 9991100..c832008 100644 --- a/procedures/procedure/Procedure.Mod +++ b/procedures/procedure/Procedure.Mod @@ -3,12 +3,13 @@ MODULE proc; IMPORT Out; + PROCEDURE printSum(a, b : INTEGER); BEGIN - Out.Int(a + b, 0); Out.Ln + Out.Int(a + b, 0); Out.Ln END printSum; BEGIN - printSum(6, 9) + printSum(6, 9) END proc. diff --git a/procedures/var-parameter/VarParam.Mod b/procedures/var-parameter/VarParam.Mod index d0d2546..19d1d8a 100644 --- a/procedures/var-parameter/VarParam.Mod +++ b/procedures/var-parameter/VarParam.Mod @@ -1,22 +1,24 @@ MODULE varparam; + IMPORT Out; -VAR - a, b : INTEGER; + +VAR a, b : INTEGER; + PROCEDURE swapVals(VAR x, y : INTEGER); VAR tmp : INTEGER; BEGIN - tmp := x; x := y; y := tmp; + tmp := x; x := y; y := tmp; END swapVals; BEGIN - a := 6; b := 9; - Out.String("initial "); Out.Ln; - Out.String("a : "); Out.Int(a, 0); Out.String("; b : "); Out.Int(b, 0); Out.Ln; - swapVals(a, b); - Out.String("after swap"); Out.Ln; - Out.String("a : "); Out.Int(a, 0); Out.String("; b : "); Out.Int(b, 0); Out.Ln; + a := 6; b := 9; + Out.String("initial "); Out.Ln; + Out.String("a : "); Out.Int(a, 0); Out.String("; b : "); Out.Int(b, 0); Out.Ln; + swapVals(a, b); + Out.String("after swap"); Out.Ln; + Out.String("a : "); Out.Int(a, 0); Out.String("; b : "); Out.Int(b, 0); Out.Ln; END varparam. diff --git a/value-types/Values.Mod b/value-types/Values.Mod index cbe04a9..b8b976b 100644 --- a/value-types/Values.Mod +++ b/value-types/Values.Mod @@ -5,8 +5,8 @@ IMPORT Out; BEGIN - Out.String("Oberon has types, for example, I am a string type (ARRAY OF CHAR);"); Out.Ln; - Out.String("There are also other types, e.g. INTEGERs and BOOLEANs"); Out.Ln; - Out.Int(42, 0); - Out.Ln + Out.String("Oberon has types, for example, I am a string type (ARRAY OF CHAR);"); Out.Ln; + Out.String("There are also other types, e.g. INTEGERs and BOOLEANs"); Out.Ln; + Out.Int(42, 0); + Out.Ln END values. diff --git a/variables/Variables.Mod b/variables/Variables.Mod index 4fc97b6..3630f19 100644 --- a/variables/Variables.Mod +++ b/variables/Variables.Mod @@ -4,28 +4,28 @@ IMPORT Out; VAR - s : ARRAY 32 OF CHAR; - i : REAL; - n, m : INTEGER; + s : ARRAY 32 OF CHAR; + i : REAL; + n, m : INTEGER; BEGIN - s := "Initial"; - Out.String(s); Out.Ln; - i := 3.14; - n := 64; - m := 42; - Out.Int(m, 0); Out.Ln; - Out.Int(n, 0); Out.Ln; - Out.Real(i, 0); Out.Ln; + s := "Initial"; + Out.String(s); Out.Ln; + i := 3.14; + n := 64; + m := 42; + Out.Int(m, 0); Out.Ln; + Out.Int(n, 0); Out.Ln; + Out.Real(i, 0); Out.Ln; - s := "assigning new values"; - Out.String(s); Out.Ln; - i := 2.71; - n := 128; - m := 84; - Out.Int(m, 0); Out.Ln; - Out.Int(n, 0); Out.Ln; - Out.Real(i, 0); - Out.Ln + s := "assigning new values"; + Out.String(s); Out.Ln; + i := 2.71; + n := 128; + m := 84; + Out.Int(m, 0); Out.Ln; + Out.Int(n, 0); Out.Ln; + Out.Real(i, 0); + Out.Ln END variables.