Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Exceptions/Aime/exceptions-1.aime
Normal file
25
Task/Exceptions/Aime/exceptions-1.aime
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
void
|
||||
throwing(void)
|
||||
{
|
||||
o_text("throwing...\n");
|
||||
error("now!");
|
||||
}
|
||||
|
||||
void
|
||||
catching(void)
|
||||
{
|
||||
o_text("ready to catch\n");
|
||||
if (trap(throwing)) {
|
||||
o_text("caught!\n");
|
||||
} else {
|
||||
# nothing was thrown
|
||||
}
|
||||
}
|
||||
|
||||
integer
|
||||
main(void)
|
||||
{
|
||||
catching();
|
||||
|
||||
return 0;
|
||||
}
|
||||
39
Task/Exceptions/Aime/exceptions-2.aime
Normal file
39
Task/Exceptions/Aime/exceptions-2.aime
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
void
|
||||
ft(integer a, text &s)
|
||||
{
|
||||
if (a & 1) {
|
||||
s = "odd";
|
||||
error("bad number");
|
||||
} elif (a & a - 1) {
|
||||
s = "not a power of two";
|
||||
error("bad number");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fc(integer a)
|
||||
{
|
||||
text e;
|
||||
|
||||
if (trap(ft, a, e)) {
|
||||
v_text("exception of type `");
|
||||
v_text(e);
|
||||
v_text("' thrown for ");
|
||||
v_integer(a);
|
||||
v_newline();
|
||||
} else {
|
||||
v_text("no exception thrown for ");
|
||||
v_integer(a);
|
||||
v_newline();
|
||||
}
|
||||
}
|
||||
|
||||
integer
|
||||
main(void)
|
||||
{
|
||||
fc(5);
|
||||
fc(6);
|
||||
fc(8);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue