changed tabs with spaces

This commit is contained in:
antranigv 2017-06-09 13:10:12 +04:00
parent e49b38df73
commit d110fb0ac8
No known key found for this signature in database
GPG key ID: 60686B14DAB81456
12 changed files with 132 additions and 119 deletions

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -5,6 +5,6 @@ IMPORT Console;
BEGIN
Console.String("Hello World!");
Console.Ln
Console.String("Hello World!");
Console.Ln
END hello.

View file

@ -5,5 +5,5 @@ IMPORT Out;
BEGIN
Out.String("Hello, World"); Out.Ln
Out.String("Hello, World"); Out.Ln
END hello.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.

View file

@ -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.