feature #6 - preliminary implementation, cannot nest yet
[svn/Cll1h/.git] / demos / exceptions / exceptions.c
diff --git a/demos/exceptions/exceptions.c b/demos/exceptions/exceptions.c
new file mode 100644 (file)
index 0000000..de07215
--- /dev/null
@@ -0,0 +1,58 @@
+#include "cll1.h"
+
+void pokus(int i)
+{
+ if(i==2)
+ {
+  fail(666);
+ }
+ if(i==7)
+ {
+  pokus(2);
+ }
+ if(i==6)
+ {
+  fail(0);
+ }
+ printf("nuda #%d\n",i);
+}
+
+program
+{
+ try
+ {
+  pokus(1);
+  pokus(2);
+  pokus(6); 
+  pokus(7); 
+ }
+ else_switch_exceptions
+ {
+  case 666: puts("chyba 666"); break;
+  default : puts("sorry, vole, error!");
+ }
+
+ try
+ {
+  pokus(1);
+  pokus(3);
+  pokus(6); 
+  pokus(2);
+  pokus(7); 
+ }
+ else_switch_exceptions
+ {
+  case 666: puts("chyba 666"); break;
+  default : puts("sorry, vole, error!");
+ }
+
+ try
+ {
+  pokus(1); 
+  pokus(7); 
+ }
+ else_catch_exception(666)
+ {
+  puts("tak, a basta.");
+ }
+}
This page took 0.159806 seconds and 4 git commands to generate.