| 1 |
(* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. *) |
| 2 |
(* This file is part of GNU Modula-2. |
| 3 |
|
| 4 |
GNU Modula-2 is free software; you can redistribute it and/or modify it under |
| 5 |
the terms of the GNU General Public License as published by the Free |
| 6 |
Software Foundation; either version 2, or (at your option) any later |
| 7 |
version. |
| 8 |
|
| 9 |
GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY |
| 10 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 |
for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License along |
| 15 |
with gm2; see the file COPYING. If not, write to the Free Software |
| 16 |
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *) |
| 17 |
MODULE expr ; |
| 18 |
|
| 19 |
FROM libc IMPORT exit ; |
| 20 |
|
| 21 |
VAR |
| 22 |
i, j: INTEGER ; |
| 23 |
BEGIN |
| 24 |
IF 6 DIV 2#3 |
| 25 |
THEN |
| 26 |
exit(1) |
| 27 |
END ; |
| 28 |
IF 6 MOD 2#0 |
| 29 |
THEN |
| 30 |
exit(2) |
| 31 |
END ; |
| 32 |
IF 1 DIV 3#0 |
| 33 |
THEN |
| 34 |
exit(3) |
| 35 |
END ; |
| 36 |
IF 1 MOD 3#1 |
| 37 |
THEN |
| 38 |
exit(4) |
| 39 |
END ; |
| 40 |
IF -3 DIV 2#-1 |
| 41 |
THEN |
| 42 |
exit(5) |
| 43 |
END ; |
| 44 |
IF 3 DIV (-2)#-1 (* we must surround the -2 in parenthenesis as `DIV' `-' is illegal *) |
| 45 |
THEN |
| 46 |
exit(6) |
| 47 |
END ; |
| 48 |
|
| 49 |
(* and the same for variables *) |
| 50 |
|
| 51 |
i := 6 ; |
| 52 |
j := 2 ; |
| 53 |
IF i DIV j#3 |
| 54 |
THEN |
| 55 |
exit(7) |
| 56 |
END ; |
| 57 |
i := 6 ; |
| 58 |
j := 2 ; |
| 59 |
IF i MOD j#0 |
| 60 |
THEN |
| 61 |
exit(8) |
| 62 |
END ; |
| 63 |
i := 1 ; |
| 64 |
j := 3 ; |
| 65 |
IF i DIV j#0 |
| 66 |
THEN |
| 67 |
exit(9) |
| 68 |
END ; |
| 69 |
i := 1 ; |
| 70 |
j := 3 ; |
| 71 |
IF i MOD j#1 |
| 72 |
THEN |
| 73 |
exit(10) |
| 74 |
END ; |
| 75 |
i := -3 ; |
| 76 |
j := 2 ; |
| 77 |
IF i DIV j#-1 |
| 78 |
THEN |
| 79 |
exit(11) |
| 80 |
END ; |
| 81 |
|
| 82 |
i := 3 ; |
| 83 |
j := -2 ; |
| 84 |
IF i DIV j#-1 |
| 85 |
THEN |
| 86 |
exit(12) |
| 87 |
END ; |
| 88 |
END expr. |