32-compare.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /* -*-comment-start: "//";comment-end:""-*-
  2. * GNU Mes --- Maxwell Equations of Software
  3. * Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  4. *
  5. * This file is part of GNU Mes.
  6. *
  7. * GNU Mes is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * GNU Mes is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <mes/lib-mini.h>
  21. int
  22. isid (char c)
  23. {
  24. return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_';
  25. }
  26. int
  27. main (int c)
  28. {
  29. int f = 0;
  30. int t = 1;
  31. int one = t;
  32. oputs ("\n");
  33. oputs ("t: if (f)\n");
  34. if (f)
  35. return 1;
  36. oputs ("t: if (one != 1)\n");
  37. if (one != 1)
  38. return 2;
  39. oputs ("t: if (1 != one)\n");
  40. if (1 != one)
  41. return 3;
  42. oputs ("t: if (one > 1)\n");
  43. if (one > 1)
  44. return 4;
  45. oputs ("t: if (one < 0)\n");
  46. if (one < 0)
  47. return 5;
  48. oputs ("t: if (one <= 0)\n");
  49. if (one <= 0)
  50. return 6;
  51. oputs ("t: if (one >= 2)\n");
  52. if (one >= 2)
  53. return 7;
  54. oputs ("t: if (!1)\n");
  55. if (!1)
  56. return 8;
  57. oputs ("t: if (one == 0)\n");
  58. if (one == 0)
  59. return 9;
  60. oputs ("t: if (f != 0)\n");
  61. if (one != 1)
  62. return 10;
  63. oputs ("t: if (1)\n");
  64. if (1)
  65. goto ok0;
  66. return 111;
  67. ok0:
  68. oputs ("t: if (0); return 1; else;\n");
  69. if (0)
  70. return 12;
  71. else
  72. goto ok1;
  73. ok1:
  74. oputs ("t: if (t)\n");
  75. if (t)
  76. goto ok2;
  77. return 13;
  78. ok2:
  79. oputs ("t: if (one > 0)\n");
  80. if (one > 0)
  81. goto ok3;
  82. return 14;
  83. ok3:
  84. oputs ("t: if (one < 2)\n");
  85. if (one < 2)
  86. goto ok4;
  87. return 15;
  88. ok4:
  89. oputs ("t: if (one >= 0)\n");
  90. if (one >= 0)
  91. goto ok5;
  92. return 16;
  93. ok5:
  94. oputs ("t: if (one >= 1)\n");
  95. if (one >= 0)
  96. goto ok6;
  97. return 17;
  98. ok6:
  99. oputs ("t: if (one <= 2)\n");
  100. if (one <= 2)
  101. goto ok7;
  102. return 18;
  103. ok7:
  104. oputs ("t: if (one <= 1)\n");
  105. if (one <= 1)
  106. goto ok8;
  107. return 19;
  108. ok8:
  109. oputs ("t: if (!0)\n");
  110. if (!0)
  111. goto ok9;
  112. return 20;
  113. ok9:
  114. oputs ("t: if (one == 1)\n");
  115. if (one == 1)
  116. goto ok10;
  117. return 21;
  118. ok10:
  119. oputs ("t: if (one != 0)\n");
  120. if (one != 0)
  121. goto ok11;
  122. return 22;
  123. ok11:
  124. ;
  125. int m1 = -1;
  126. int i;
  127. oputs ("t: i = one > 0\n");
  128. i = one > 0;
  129. if (!i)
  130. return 23;
  131. oputs ("t: i = one >= 1\n");
  132. i = one >= 1;
  133. if (!i)
  134. return 24;
  135. oputs ("t: i = one < 2\n");
  136. i = one < 2;
  137. if (!i)
  138. return 25;
  139. oputs ("t: i = one <= 1\n");
  140. i = one <= 1;
  141. if (!i)
  142. return 26;
  143. oputs ("t: i = 0 > one\n");
  144. i = 0 > one;
  145. if (i)
  146. return 27;
  147. oputs ("t: i = 0 >= one\n");
  148. i = 0 >= one;
  149. if (i)
  150. return 28;
  151. oputs ("t: i = 1 < one \n");
  152. i = 1 < one;
  153. if (i)
  154. return 29;
  155. oputs ("t: i = 2 <= one\n");
  156. i = 2 <= one;
  157. if (i)
  158. return 30;
  159. oputs ("t: i = m1 > -2\n");
  160. i = m1 > -2;
  161. if (!i)
  162. return 31;
  163. oputs ("t: i = m1 >= -1\n");
  164. i = m1 >= -1;
  165. if (!i)
  166. return 32;
  167. oputs ("t: i = m1 < 0\n");
  168. i = m1 < 0;
  169. if (!i)
  170. return 33;
  171. oputs ("t: i = m1 <= -1\n");
  172. i = m1 <= -1;
  173. if (!i)
  174. return 34;
  175. oputs ("t: i = -1 > m1\n");
  176. i = -1 > m1;
  177. if (i)
  178. return 35;
  179. oputs ("t: i = -2 >= m1\n");
  180. i = -2 >= m1;
  181. if (i)
  182. return 36;
  183. oputs ("t: i = -1 < m1 \n");
  184. i = -1 < m1;
  185. if (i)
  186. return 37;
  187. oputs ("t: i = -2 <= m1\n");
  188. i = 0 <= m1;
  189. if (i)
  190. return 38;
  191. oputs ("t: isid (0)\n");
  192. if (isid (0))
  193. return 39;
  194. oputs ("t: isid (6)\n");
  195. if (isid (6))
  196. return 40;
  197. oputs ("t: isid (a)\n");
  198. if (isid ('a') != 1)
  199. return 41;
  200. oputs ("t: isid ( )\n");
  201. if (isid (' '))
  202. return 42;
  203. return 0;
  204. }