From 90042d221d64abed41dbb8010c3f699259c3f2a1 Mon Sep 17 00:00:00 2001 From: MightyPork Date: Fri, 26 Dec 2014 10:23:59 +0100 Subject: [PATCH] yeolde --- devel/lib/loops.h | 3 --- devel/lib/yeolde.h | 29 ++++++++++++++++++++++++ devel/lib_tests/test_loops_visual.c | 10 ++++---- devel/lib_tests/test_yeolde.c | 34 ++++++++++++++++++++++++++++ devel/lib_tests/x | Bin 0 -> 6828 bytes 5 files changed, 68 insertions(+), 8 deletions(-) create mode 100644 devel/lib/yeolde.h create mode 100644 devel/lib_tests/test_yeolde.c create mode 100755 devel/lib_tests/x diff --git a/devel/lib/loops.h b/devel/lib/loops.h index 401c249..4fa963e 100644 --- a/devel/lib/loops.h +++ b/devel/lib/loops.h @@ -20,6 +20,3 @@ // Do until condition is met #define until(what) while(!(what)) -// Because why the hell not -#define whilst(what) while((what)) - diff --git a/devel/lib/yeolde.h b/devel/lib/yeolde.h new file mode 100644 index 0000000..77afa71 --- /dev/null +++ b/devel/lib/yeolde.h @@ -0,0 +1,29 @@ +#pragma once + +/** + Ye Olde Control Structures +*/ + +#include "loops.h" + +#define whilst(what) while((what)) +#define when(what) if((what)) +#define otherwise else +#define commence { +#define then { +#define cease } +#define choose(what) switch((what)) +#define option case +#define shatter break +#define replay continue +#define equals == +#define is == +#define be = +#define over > +#define above > +#define under < +#define below < +#define let /**/ +#define raise(what) (what)++ + +#define number int diff --git a/devel/lib_tests/test_loops_visual.c b/devel/lib_tests/test_loops_visual.c index d604d56..2fd1a33 100644 --- a/devel/lib_tests/test_loops_visual.c +++ b/devel/lib_tests/test_loops_visual.c @@ -12,15 +12,15 @@ void main() printf("\n"); int i = 0; until (i == 100) i++; - - whilst (i > 0) { + + until (i == 0) { i--; printf("i = %d\n", i); } - + printf("\n"); - + loop(moo, 7) { printf("moo = %d\n", moo); } -} \ No newline at end of file +} diff --git a/devel/lib_tests/test_yeolde.c b/devel/lib_tests/test_yeolde.c new file mode 100644 index 0000000..823fed0 --- /dev/null +++ b/devel/lib_tests/test_yeolde.c @@ -0,0 +1,34 @@ +#include +#include +#include +#include + +#include "lib/loops.h" +#include "lib/yeolde.h" + +void main() +commence + let number a be 0; + whilst (a under 13) + commence + raise (a); + + when (a is 5) + then + printf("A is ugly 5\n"); + replay; + cease; + + choose (a) + commence + option 1: + printf("A is 1\n"); + shatter; + option 2: + printf("A is 2\n"); + shatter; + option 3: + printf("Neither 1 nor 2\n"); + cease; + cease; +cease diff --git a/devel/lib_tests/x b/devel/lib_tests/x new file mode 100755 index 0000000000000000000000000000000000000000..532da17b137a63fe4ef90a952943aae78f976d7a GIT binary patch literal 6828 zcmcIoeQX?85ue+;vz@Q=IZazP3CSuXk{ijF#3aW3O7{Gfb#zHg;)I~$?45lZ-<9*7 zb+;GnNChLe1*@ch0D%w^`3ICgstTzB3X!m*pr%NGQX~YTAXz9$le$H&5~2vDIcDC@ z*n8^>s)TsbzM1*W$D8-|eeByW_au6?Kmep@uop;*h71L{HNd%*N@T198o+=}umS22 z3FBiZ4N;d9I?JJjHn3d~X^41@0nKn3rW;)egi3})slBCQFzeDpy(c_DkUU=>G;S1L`8m~XwJMvfZl?U06T~?vx z+8WlBPc3{4;(85x!2S(WciLgB?3BQ=2(U^{s_0mwscasRk!<@Rh&_B?3d3G*rfO+}im?D?!klgqM8s0wDxVanPjjv+D z$IRAAB<9rJh&g@j^oBR6IZCr>aE26>IW&HOKp4Dqib_o6Uz7fr`IUdF02l8EF@QO} zU|zhj&kVe2zJ1?$crn^4iPpH8;;8l~pZR4-2PiikL&qC=OlhdMEKX<E)5! zguch+ce$hu4%t~JV;A*ZdcIK9+i)lX8-h>KUPF8CPd}|I_6FHTqP>yk z1C6V`*f0tE)<3oVQ(LzXOg1>Y(2hCT1jHlJm$a@mby^Zzc6DilCq>^GiGD-tj5NOz z?1|`SL!FV9uZPXZ&X?-UNXJzD;fOI7>4-;m#v?7A5gqN&zBAIG_PbXx&UuWZQ9Hge z7cvww%T&~|_Jyuy#rdFXzlP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