2017-07-09 07:24:07 +00:00
|
|
|
/* -*-comment-start: "//";comment-end:""-*-
|
2018-07-22 12:24:36 +00:00
|
|
|
* GNU Mes --- Maxwell Equations of Software
|
2018-05-19 09:41:53 +00:00
|
|
|
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
2017-07-09 07:24:07 +00:00
|
|
|
*
|
2018-07-22 12:24:36 +00:00
|
|
|
* This file is part of GNU Mes.
|
2017-07-09 07:24:07 +00:00
|
|
|
*
|
2018-07-22 12:24:36 +00:00
|
|
|
* GNU Mes is free software; you can redistribute it and/or modify it
|
2017-07-09 07:24:07 +00:00
|
|
|
* under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
2018-07-22 12:24:36 +00:00
|
|
|
* GNU Mes is distributed in the hope that it will be useful, but
|
2017-07-09 07:24:07 +00:00
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-22 12:24:36 +00:00
|
|
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
2017-07-09 07:24:07 +00:00
|
|
|
*/
|
|
|
|
|
2018-08-15 16:01:14 +00:00
|
|
|
#include <libmes.h>
|
2017-07-09 07:24:07 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2017-07-29 18:46:16 +00:00
|
|
|
int isid(char c) {
|
|
|
|
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_';
|
|
|
|
}
|
|
|
|
|
2017-07-09 07:24:07 +00:00
|
|
|
int
|
2018-08-15 16:01:14 +00:00
|
|
|
main ()
|
2017-07-09 07:24:07 +00:00
|
|
|
{
|
|
|
|
int f = 0;
|
|
|
|
int t = 1;
|
|
|
|
int one = t;
|
|
|
|
|
|
|
|
puts ("\n");
|
|
|
|
puts ("t: if (f)\n");
|
|
|
|
if (f) return 1;
|
|
|
|
|
|
|
|
puts ("t: if (one != 1)\n");
|
2018-05-19 09:41:53 +00:00
|
|
|
if (one != 1) return 2;
|
2017-07-09 07:24:07 +00:00
|
|
|
|
|
|
|
puts ("t: if (1 != one)\n");
|
2018-05-19 09:41:53 +00:00
|
|
|
if (1 != one) return 3;
|
2017-07-09 07:24:07 +00:00
|
|
|
|
|
|
|
puts ("t: if (one > 1)\n");
|
2018-05-19 09:41:53 +00:00
|
|
|
if (one > 1) return 4;
|
2017-07-09 07:24:07 +00:00
|
|
|
|
|
|
|
puts ("t: if (one < 0)\n");
|
2018-05-19 09:41:53 +00:00
|
|
|
if (one < 0) return 5;
|
2017-07-09 07:24:07 +00:00
|
|
|
|
|
|
|
puts ("t: if (one <= 0)\n");
|
2018-05-19 09:41:53 +00:00
|
|
|
if (one <= 0) return 6;
|
2017-07-09 07:24:07 +00:00
|
|
|
|
|
|
|
puts ("t: if (one >= 2)\n");
|
2018-05-19 09:41:53 +00:00
|
|
|
if (one >= 2) return 7;
|
2017-07-09 07:24:07 +00:00
|
|
|
|
|
|
|
puts ("t: if (!1)\n");
|
2018-05-19 09:41:53 +00:00
|
|
|
if (!1) return 8;
|
2017-07-09 07:24:07 +00:00
|
|
|
|
|
|
|
puts ("t: if (one == 0)\n");
|
2018-05-19 09:41:53 +00:00
|
|
|
if (one == 0) return 9;
|
2017-07-09 07:24:07 +00:00
|
|
|
|
|
|
|
puts ("t: if (f != 0)\n");
|
2018-05-19 09:41:53 +00:00
|
|
|
if (one != 1) return 10;
|
2017-07-09 07:24:07 +00:00
|
|
|
|
|
|
|
puts ("t: if (1)\n");
|
|
|
|
if (1) goto ok0;
|
2018-05-19 09:41:53 +00:00
|
|
|
return 111;
|
2017-07-09 07:24:07 +00:00
|
|
|
ok0:
|
|
|
|
|
|
|
|
puts ("t: if (0); return 1; else;\n");
|
2018-05-19 09:41:53 +00:00
|
|
|
if (0) return 12; else goto ok1;
|
2017-07-09 07:24:07 +00:00
|
|
|
ok1:
|
|
|
|
|
|
|
|
puts ("t: if (t)\n");
|
|
|
|
if (t) goto ok2;
|
2018-05-19 09:41:53 +00:00
|
|
|
return 13;
|
2017-07-09 07:24:07 +00:00
|
|
|
ok2:
|
|
|
|
|
|
|
|
puts ("t: if (one > 0)\n");
|
|
|
|
if (one > 0) goto ok3;
|
2018-05-19 09:41:53 +00:00
|
|
|
return 14;
|
2017-07-09 07:24:07 +00:00
|
|
|
ok3:
|
|
|
|
|
|
|
|
puts ("t: if (one < 2)\n");
|
|
|
|
if (one < 2) goto ok4;
|
2018-05-19 09:41:53 +00:00
|
|
|
return 15;
|
2017-07-09 07:24:07 +00:00
|
|
|
ok4:
|
|
|
|
|
|
|
|
puts ("t: if (one >= 0)\n");
|
|
|
|
if (one >= 0) goto ok5;
|
2018-05-19 09:41:53 +00:00
|
|
|
return 16;
|
2017-07-09 07:24:07 +00:00
|
|
|
ok5:
|
|
|
|
|
|
|
|
puts ("t: if (one >= 1)\n");
|
|
|
|
if (one >= 0) goto ok6;
|
2018-05-19 09:41:53 +00:00
|
|
|
return 17;
|
2017-07-09 07:24:07 +00:00
|
|
|
ok6:
|
|
|
|
|
|
|
|
puts ("t: if (one <= 2)\n");
|
|
|
|
if (one <= 2) goto ok7;
|
2018-05-19 09:41:53 +00:00
|
|
|
return 18;
|
2017-07-09 07:24:07 +00:00
|
|
|
ok7:
|
|
|
|
|
|
|
|
puts ("t: if (one <= 1)\n");
|
|
|
|
if (one <= 1) goto ok8;
|
2018-05-19 09:41:53 +00:00
|
|
|
return 19;
|
2017-07-09 07:24:07 +00:00
|
|
|
ok8:
|
|
|
|
|
|
|
|
puts ("t: if (!0)\n");
|
|
|
|
if (!0) goto ok9;
|
2018-05-19 09:41:53 +00:00
|
|
|
return 20;
|
2017-07-09 07:24:07 +00:00
|
|
|
ok9:
|
|
|
|
|
|
|
|
puts ("t: if (one == 1)\n");
|
|
|
|
if (one == 1) goto ok10;
|
2018-05-19 09:41:53 +00:00
|
|
|
return 21;
|
2017-07-09 07:24:07 +00:00
|
|
|
ok10:
|
|
|
|
|
|
|
|
puts ("t: if (one != 0)\n");
|
|
|
|
if (one != 0) goto ok11;
|
2018-05-19 09:41:53 +00:00
|
|
|
return 22;
|
2017-07-09 07:24:07 +00:00
|
|
|
ok11:
|
2017-07-29 18:46:16 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
int m1 = -1;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
puts ("t: i = one > 0\n");
|
|
|
|
i = one > 0;
|
2018-05-19 09:41:53 +00:00
|
|
|
if (!i) return 23;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
puts ("t: i = one >= 1\n");
|
|
|
|
i = one >= 1;
|
2018-05-19 09:41:53 +00:00
|
|
|
if (!i) return 24;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
puts ("t: i = one < 2\n");
|
|
|
|
i = one < 2;
|
2018-05-19 09:41:53 +00:00
|
|
|
if (!i) return 25;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
puts ("t: i = one <= 1\n");
|
|
|
|
i = one <= 1;
|
2018-05-19 09:41:53 +00:00
|
|
|
if (!i) return 26;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
puts ("t: i = 0 > one\n");
|
|
|
|
i = 0 > one;
|
2018-05-19 09:41:53 +00:00
|
|
|
if (i) return 27;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
puts ("t: i = 0 >= one\n");
|
|
|
|
i = 0 >= one;
|
2018-05-19 09:41:53 +00:00
|
|
|
if (i) return 28;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
puts ("t: i = 1 < one \n");
|
|
|
|
i = 1 < one;
|
2018-05-19 09:41:53 +00:00
|
|
|
if (i) return 29;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
puts ("t: i = 2 <= one\n");
|
|
|
|
i = 2 <= one;
|
2018-05-19 09:41:53 +00:00
|
|
|
if (i) return 30;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
puts ("t: i = m1 > -2\n");
|
|
|
|
i = m1 > -2;
|
2018-05-19 09:41:53 +00:00
|
|
|
if (!i) return 31;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
puts ("t: i = m1 >= -1\n");
|
|
|
|
i = m1 >= -1;
|
2018-05-19 09:41:53 +00:00
|
|
|
if (!i) return 32;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
puts ("t: i = m1 < 0\n");
|
|
|
|
i = m1 < 0;
|
2018-05-19 09:41:53 +00:00
|
|
|
if (!i) return 33;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
puts ("t: i = m1 <= -1\n");
|
|
|
|
i = m1 <= -1;
|
2018-05-19 09:41:53 +00:00
|
|
|
if (!i) return 34;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
puts ("t: i = -1 > m1\n");
|
|
|
|
i = -1 > m1;
|
2018-05-19 09:41:53 +00:00
|
|
|
if (i) return 35;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
puts ("t: i = -2 >= m1\n");
|
|
|
|
i = -2 >= m1;
|
2018-05-19 09:41:53 +00:00
|
|
|
if (i) return 36;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
puts ("t: i = -1 < m1 \n");
|
|
|
|
i = -1 < m1;
|
2018-05-19 09:41:53 +00:00
|
|
|
if (i) return 37;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
puts ("t: i = -2 <= m1\n");
|
|
|
|
i = 0 <= m1;
|
2018-05-19 09:41:53 +00:00
|
|
|
if (i) return 38;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
puts ("t: isid (0)\n");
|
2018-05-19 09:41:53 +00:00
|
|
|
if (isid (0)) return 39;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
puts ("t: isid (6)\n");
|
|
|
|
|
2018-05-19 09:41:53 +00:00
|
|
|
if (isid (6)) return 40;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
puts ("t: isid (a)\n");
|
2018-05-19 09:41:53 +00:00
|
|
|
if (isid ('a') != 1) return 41;
|
2017-07-29 18:46:16 +00:00
|
|
|
|
|
|
|
puts ("t: isid ( )\n");
|
2018-05-19 09:41:53 +00:00
|
|
|
if (isid (' ')) return 42;
|
2017-07-09 07:24:07 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|