From e63f1bc2438012b5f2f6592a474892501149af18 Mon Sep 17 00:00:00 2001 From: xchaos Date: Tue, 19 Apr 2011 12:18:15 +0000 Subject: [PATCH] preparing 0.9 version, rename to crl1.h git-svn-id: https://dev.arachne.cz/repos/cll1h/trunk@131 4bb87942-c103-4e5a-b51c-0ebff58f8515 --- README | 5 +- cll1.h | 429 ------------------------- demos/advanced-hello-world.c | 35 -- demos/ansi-c/float-list-plain-c.c | 60 ---- demos/ansi-c/objects-c.c | 107 ------ demos/ansi-c/objects-c99.c | 134 -------- demos/ansi-c/print-c99.c | 12 - demos/arguments1.c | 27 -- demos/arguments2.c | 27 -- demos/boolean.c | 22 -- demos/cll1.h | 1 - demos/column.c | 12 - demos/columns.c | 16 - demos/eq.c | 49 --- demos/exceptions/advanced-failures.c | 66 ---- demos/exceptions/failures.c | 75 ----- demos/fastcgi/fastcgi.c | 16 - demos/for_ints_strs.c | 15 - demos/for_range.c | 51 --- demos/hello.c | 6 - demos/idmap.c | 94 ------ demos/lists/cll1.h | 1 - demos/lists/float-list-ordered.c | 25 -- demos/lists/float-list-plain.c | 29 -- demos/lists/lists.c | 95 ------ demos/locale.c | 27 -- demos/mysql/mysql.c | 15 - demos/objects/objects-community.c | 315 ------------------ demos/objects/objects-federation.c | 342 -------------------- demos/objects/objects-wiki.c | 74 ----- demos/performance/cll1-echo.c | 8 - demos/performance/cll1-print.c | 7 - demos/performance/cll1-print2.c | 7 - demos/performance/cll1.h | 1 - demos/performance/cout.cpp | 12 - demos/performance/cout2.cpp | 11 - demos/performance/echo.php | 7 - demos/performance/echo2.php | 7 - demos/performance/fputs.c | 12 - demos/performance/fputs2.c | 14 - demos/performance/fwrite.c | 16 - demos/performance/fwrite2.c | 21 -- demos/performance/print.pl | 8 - demos/performance/print.py | 5 - demos/performance/print.rb | 4 - demos/performance/print2.pl | 7 - demos/performance/print2.py | 5 - demos/performance/print2.rb | 4 - demos/performance/printf.c | 12 - demos/performance/printf2.c | 12 - demos/performance/puts.c | 12 - demos/performance/run-tests.sh | 3 - demos/performance/test-performance.sh | 129 -------- demos/performance/test-performance2.sh | 114 ------- demos/performance/test-results | 342 -------------------- demos/performance/test-results2 | 297 ----------------- demos/performance/write.c | 15 - demos/performance/write2.c | 20 -- demos/performance/xrange.py | 5 - demos/performance/xrange2.py | 5 - demos/repeat.c | 36 --- demos/seznamy.c | 63 ---- demos/shell.c | 26 -- demos/split.c | 37 --- demos/strings.c | 13 - demos/stromecek.c | 18 -- demos/trees.c | 70 ---- tools/bake | 59 ---- tools/bake.conf | 5 - tools/cake.c | 40 --- 70 files changed, 2 insertions(+), 3669 deletions(-) delete mode 100644 cll1.h delete mode 100644 demos/advanced-hello-world.c delete mode 100644 demos/ansi-c/float-list-plain-c.c delete mode 100644 demos/ansi-c/objects-c.c delete mode 100644 demos/ansi-c/objects-c99.c delete mode 100644 demos/ansi-c/print-c99.c delete mode 100644 demos/arguments1.c delete mode 100644 demos/arguments2.c delete mode 100644 demos/boolean.c delete mode 120000 demos/cll1.h delete mode 100644 demos/column.c delete mode 100644 demos/columns.c delete mode 100644 demos/eq.c delete mode 100644 demos/exceptions/advanced-failures.c delete mode 100644 demos/exceptions/failures.c delete mode 100644 demos/fastcgi/fastcgi.c delete mode 100644 demos/for_ints_strs.c delete mode 100644 demos/for_range.c delete mode 100644 demos/hello.c delete mode 100644 demos/idmap.c delete mode 120000 demos/lists/cll1.h delete mode 100644 demos/lists/float-list-ordered.c delete mode 100644 demos/lists/float-list-plain.c delete mode 100644 demos/lists/lists.c delete mode 100644 demos/locale.c delete mode 100644 demos/mysql/mysql.c delete mode 100644 demos/objects/objects-community.c delete mode 100644 demos/objects/objects-federation.c delete mode 100644 demos/objects/objects-wiki.c delete mode 100644 demos/performance/cll1-echo.c delete mode 100644 demos/performance/cll1-print.c delete mode 100644 demos/performance/cll1-print2.c delete mode 120000 demos/performance/cll1.h delete mode 100644 demos/performance/cout.cpp delete mode 100644 demos/performance/cout2.cpp delete mode 100755 demos/performance/echo.php delete mode 100755 demos/performance/echo2.php delete mode 100644 demos/performance/fputs.c delete mode 100644 demos/performance/fputs2.c delete mode 100644 demos/performance/fwrite.c delete mode 100644 demos/performance/fwrite2.c delete mode 100755 demos/performance/print.pl delete mode 100755 demos/performance/print.py delete mode 100755 demos/performance/print.rb delete mode 100755 demos/performance/print2.pl delete mode 100755 demos/performance/print2.py delete mode 100755 demos/performance/print2.rb delete mode 100644 demos/performance/printf.c delete mode 100644 demos/performance/printf2.c delete mode 100644 demos/performance/puts.c delete mode 100755 demos/performance/run-tests.sh delete mode 100755 demos/performance/test-performance.sh delete mode 100755 demos/performance/test-performance2.sh delete mode 100644 demos/performance/test-results delete mode 100644 demos/performance/test-results2 delete mode 100644 demos/performance/write.c delete mode 100644 demos/performance/write2.c delete mode 100755 demos/performance/xrange.py delete mode 100755 demos/performance/xrange2.py delete mode 100644 demos/repeat.c delete mode 100644 demos/seznamy.c delete mode 100644 demos/shell.c delete mode 100644 demos/split.c delete mode 100644 demos/strings.c delete mode 100644 demos/stromecek.c delete mode 100644 demos/trees.c delete mode 100755 tools/bake delete mode 100644 tools/bake.conf delete mode 100644 tools/cake.c diff --git a/README b/README index b183428..83cec31 100644 --- a/README +++ b/README @@ -1,9 +1,8 @@ -C<<1 header file v - style sheet for ANSI C +C<<1 header file v 0.9 - JQuery-style library for ANSI C99 -Copyright (c)2004-2008 Michael xChaos Polak, Arachne Labs, x(at)n.cz +Copyright (c)2004-2011 Michael xChaos Polak, Arachne Labs, x(at)n.cz See https://dev.arachne.cz/svn/cll1.h for details, documentation and FAQ -(or https://orion.stresovice.czf/svn/cll1h when inside CZFree.Net). See http://www.arachne.cz/ for Arachne Labs contact and product information. diff --git a/cll1.h b/cll1.h deleted file mode 100644 index 78642ff..0000000 --- a/cll1.h +++ /dev/null @@ -1,429 +0,0 @@ - /* .---------------------------------------------------------------------. - / C<<1 header file - C language style sheet - GNU C/ANSI C99 compliant - / Cumbersome Extraction and Report Language - http://cll1h.arachne.cz/ -'---------------------------------------------------------------------- */ -/* - Copyright (c) 2004-2008 Michael xChaos Polak - x(at)n.cz - - The C<<1 header file is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The C<<1 header file is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with C<<1 header file; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ -#ifndef _CLL1_H -#define _CLL1_H -#define CLL1H_VERSION "0.7.1" -/* .----------------------------------------------------------------------. - / 0. Library definitions not parsed by @CC, updated 2008-01-26 xCh. - '---------------------------------------------------------------------- */ -/* -@define USE_LIBRARY_MYSQL -lmysqlclient -@define USE_LIBRARY_FASTCGI -lfcgi -@define USE_PREPROCESSOR cake *.html *.xml > _include.c -@define USE_POSTPROCESSOR strip @ -*/ -/* .----------------------------------------------------------------------. - / 1. C<<1 header auto include, updated 2008-01-26 xCh. - '---------------------------------------------------------------------- */ -#ifndef DISABLE_MODULE_AUTOINCLUDE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef USE_LIBRARY_FASTCGI -#include -#else -#include -#endif -#endif -#ifdef USE_LIBRARY_MYSQL -#include -#endif -/* .----------------------------------------------------------------------. - / 0. C<<1 typedefs and public global variables, updated 2008-02-03 xCh. - '----------------------------------------------------------------------- */ -typedef void * any; -typedef unsigned char * buf; /* this will be always 8-bit usigned char * */ -typedef FILE * file; -typedef int bool; -#ifdef USE_WCHAR_T -typedef wchar_t * str; -#else -typedef char * str; /* Warning: full wchar_t support not yet implemented! */ -#endif -extern str NIL, EOL, OFS, IFS, LANG, errstr; /* used for: perror(errstr) */ -extern unsigned RANDOM_SEED; -#define _EXPORT_GLOBALS \ -str NIL="(null)", EOL="\n", OFS=" ", IFS=" \t\n", LANG=NULL; \ -str errstr="C<<1 0xdead"; \ -unsigned RANDOM_SEED=0; -/* .----------------------------------------------------------------------. - / 1. C<<1 then buddhist section, updated 2008-02-04 xCh. - '----------------------------------------------------------------------- */ -#ifndef DISABLE_MODULE_THEN_BUDDHISM -#define then -#define MAYBE (int)((long)(RANDOM_SEED?random():((RANDOM_SEED=(unsigned)time(NULL)),srandom(RANDOM_SEED),random()))%2) -#define WHOKNOWS (int)(srandom((unsigned)time(NULL)),random()%2) -#define for_samsara(MIND,SOUL) for(MIND=SOUL; MIND || ((MIND->__next=SOUL),0) ; MIND=MIND->__next) -#define samsara(MIND,SOUL) for(MIND=SOUL; MIND || ((MIND->__next=SOUL),0) ; MIND=MIND->__next) -//#define atob(EXPR) (word_in_stri(YES,(EXPR))?1:0) -//#define _EXPORT_YES str YES="TRUE\nYES\nJA\nOUI\nDA\nANO\nY\n1"; -//#else -#define atob(EXPR) (eqi((EXPR),YES)?TRUE:FALSE) -#define _EXPORT_YES str YES="TRUE"; -#endif -/* .----------------------------------------------------------------------. - / 2. C<<1 almost then buddhist section, updated 2008-02-02 xCh. - '----------------------------------------------------------------------- */ -#define not ! -#define and && -#define or || -#define TRUE 1 -#define FALSE 0 -#define PI 3.141592654 -#define WEIRDINT (1<<(sizeof(int)*8-1)) -#define btoa(EXPR) ((EXPR)?"TRUE":"FALSE") -#define coalesce(VAR,EXPR) (VAR?VAR:(VAR=0,(EXPR))) -#define coalesce_str(VAR,EXPR) (VAR && *VAR?VAR:((VAR=NULL),(EXPR))) -/* .----------------------------------------------------------------------. - / 4. C<<1 data declaration and allocation, updated 2008-01-31 xCh. - '----------------------------------------------------------------------- */ -#define def_type(TYPE) typedef struct _##TYPE##_struct * TYPE -#define def_mem(TYPE) def_type(TYPE); struct _##TYPE##_struct -#define get_mem(TYPE) _GET_MEM(TYPE) -#define get_buf(SIZE) (buf)malloc(SIZE) /* temporary solution */ -#define size_of_mem(TYPE) sizeof(struct _##TYPE##_struct) -#define copy_of_mem(TYPE,SRC) _cll1_mem_cpy(sizeof(struct _##TYPE##_struct),SRC) -#define list(TYPE) TYPE __next -#define tree(TYPE) TYPE __next; TYPE __seek -#define dict(TYPE) tree(TYPE); str __key -#define array(TYPE) tree(TYPE); int __key -/* ---- variable declarators -------------------------------------------- */ -#define Get_mem(ID,TYPE) TYPE ID=get_mem(TYPE) -#define Get_buf(ID,SIZE) buf ID=get_buf(SIZE) -/* .----------------------------------------------------------------------. - / 5. C<<1 string manipulation, updated 2008-01-26 xCh. - '----------------------------------------------------------------------- */ -#define get_str(...) _cll1_get_str(__VA_ARGS__,NIL) -#define eq(A,B) (!_cll1_str_cmp(A,B)) -#define eqi(A,B) (!_cll1_str_cmpi(A,B)) -#define str_order(A,B) _cll1_str_coll(A,B) -#define str_ascii(A,B) _cll1_str_cmp(A,B) -#define chars_in_str(...) _cll1_strlen(__VA_ARGS__,NIL) -#define size_of_str(A) mbstowcs(NULL,A,0) -#define str_in(A,B) _cll1_str_str(A,B) -#define word_in(A,B) _cll1_wordinstr(A,B,0) -#define print(...) _cll1_print(__VA_ARGS__,NIL) -#define fprint(...) _cll1_fprint(__VA_ARGS__,NIL) -#define file_print(...) _cll1_fprint(_F,__VA_ARGS__,NIL) -#define echo(...) _cll1_echo(__VA_ARGS__,NIL) -#define fecho(...) _cll1_fecho(__VA_ARGS__,NIL) -#define file_echo(...) _cll1_fecho(_F,__VA_ARGS__,NIL) -#define suffix(A,B,C) (((A=strrchr(B,C))&&!(*(A++)=0))||(A=B)) -#define prefix(A,B,C) ((A=B),((B=strchr(B,C))&&!(*(B++)=0)||(B=A))) -#define tr(STR,B,C) _NEW(S,STR) while(S && *_S) { if(*_S==B)*_S=C; /* <-' */ _S++; } -/* ---- variable declarators -------------------------------------------- */ -#define Get_str(ID,...) str ID=get_str(__VA_ARGS__) -/* .----------------------------------------------------------------------. - / 6. C<<1 data container manipulation, updated 2008-01-26 xCh. - '----------------------------------------------------------------------- */ -#define push(NODE,HEAD) ( NODE ? ((NODE->__next=HEAD),(HEAD=NODE)) : NULL ) -#define pop(NODE,HEAD) ( HEAD ? ((NODE=HEAD->__next),free(HEAD),(HEAD=NODE)) : (NODE=NULL) ) -#define append(NODE,HEAD) { void *_PTR=NODE; if(NODE) NODE->__next=NULL; if(HEAD) { for_search(NODE,HEAD,!NODE->__next) { NODE->__next=_PTR; break; } } else HEAD=NODE; } -#define remove(NODE,HEAD,EXPR) { void **_D=NULL; /* <-' */ for_search(NODE,HEAD,EXPR) { if(_D)*_D=NODE->__next; else HEAD=NODE->__next; free(NODE); } else _D=(void *)&(NODE->__next); } -#define drop(NODE,HEAD) for( NODE=HEAD; NODE || (HEAD=NULL); HEAD=NODE, NODE=NODE->__next, free(HEAD) ) -//to do: seek -//to do: store -#define count(NODE,HEAD,VAR) { _NEW(I,0) for(NODE=HEAD; NODE || ((VAR=_I),0) ; (NODE=NODE->__next)?(_I++):0 ); } -#define order_by_num(K1,K2) (K1>K2) -#define order_by_num_desc(K1,K2) (K10) -#define order_by_str_desc(K1,K2) (str_order(K1,K2)<0) -#define order_by_ascii(K1,K2) (str_ascii(K1,K2)>0) -#define order_by_ascii_desc(K1,K2) (str_ascii(K1,K2)<0) -#define insert(NODE,HEAD,ORDERBY,KEY) { if(HEAD) { void **_L=NULL, *H=HEAD; /* <-' */ for_search(HEAD,H,ORDERBY(HEAD->KEY,NODE->KEY)) { if(_L) {*_L=NODE; NODE->__next=HEAD; } else push(NODE,H); break; } else _L=(void *)&(HEAD->__next); if(!HEAD)*_L=NODE; HEAD=H; } else if (NODE) { push(NODE,HEAD); HEAD->__next=NULL; } } -#define sort(NODE,HEAD,ORDERBY,KEY) { void *_NEXT; /* <-' */ NODE=HEAD; HEAD=NULL; do { _NEXT=NODE->__next; NODE->__next=NULL; insert(NODE,HEAD,ORDERBY,KEY); NODE=_NEXT; } while(_NEXT); } -/* .----------------------------------------------------------------------. - / 7. C<<1 builtin iterators and conditionals, updated 2008-01-26 xCh. - '----------------------------------------------------------------------- */ -#define loop while(TRUE) -#define repeat(N) _NEW(I,(_J=(N),0)) while(_I++<_J) /* C99 version would be: for(int _i=0,_j=(N);_i++<_j;) */ -#define for_range(VAR,FROM,TO) _NEW(I,((_J=(TO)),FROM)) for( VAR=_I ; _I<=_J?VAR<=_J:VAR>=_J ; _I<=_J?VAR++:VAR--) -#define for_each(NODE,HEAD) for(NODE=HEAD; NODE; NODE=NODE->__next) -#define for_search(NODE,HEAD,EXPR) for_each(NODE,HEAD) if(EXPR) -#define for_file_lines(STR,FNAME) /* _NEW(CTX,get_context()) file_read(FNAME) for(use_context(_CTX),STR=file_line(_F);release_context(_M),(*S && !feof(_F));STR=file_line(_F),end_context()) _CATCH */ -#define for_input_lines(S,L) /* _NEW(CTX,get_context()) for(use_context(_CTX),STR=file_get_line(stdin);release_context(_M),(*S && !feof(stdin));STR=file_get_line(stdin)) _CATCH */ -#define for_ints(VAR,...) _NEW(I,0) while( (VAR=_cll1_for_ints(_I++,__VA_ARGS__,WEIRDINT))!=WEIRDINT ) -#define for_strs(VAR,...) _NEW(I,0) while( (VAR=(char *)_cll1_for_ptrs(_I++,__VA_ARGS__,NIL))!=NIL ) -#define for_args(STR) _NEW(I,1) while(_I++1) -#define switch_for_args for_args with_str(this_arg) -#define with_str(STR) _NEW(S,STR) -#define if_case(VAL) if(eq(_S,VAL)) -#define for_fields(FIELD,STR) for_valid_split(FIELD,STR,*OFS) -#define for_split_str(A,B,C) for(prefix(A,B,C);A;(A!=B)&&prefix(A,B,C)||(A=NULL)) -#define for_valid_split(A,B,C) for_split_str(A,B,C) if(*A) -#define switch_for_columns(A,B,C) _FOR_COLUMNS(A,B,C) switch(__I) -#define switch_for_valid_columns(A,B,C) _FOR_VALID_COLUMNS(A,B,C) switch (_I) -#define if_column_number(A,B,C,V) _FOR_COLUMNS(A,B,C) if(_I==V) -#define if_valid_column_number(A,B,C,V) _FOR_VALID_COLUMNS(A,B,C) if(_I==V) -/* .----------------------------------------------------------------------. - / 8. C<<1 object oriented infrastructure, updated 2008-02-04 - '----------------------------------------------------------------------- */ -#define def_interface(TYPE,INTERFACE) def_type(TYPE); def_mem(INTERFACE) -#define def_obj(TYPE) struct _##TYPE##_struct -#define interface(TYPE) TYPE __interface -#define interface_of(SELF) SELF->__interface -#define method(NAME) (*NAME) -#define construct(TYPE,INTERFACE) TYPE _init_##TYPE(TYPE o,INTERFACE i) { o->__interface=i; return o; } TYPE __init__##TYPE -#define get_obj(TYPE,INTERFACE,...) __init__##TYPE(_init_##TYPE(get_mem(TYPE),INTERFACE),__VA_ARGS__) -#define get_obj_as(COMMUNITY,MEM,INTERFACE,...) (COMMUNITY)get_obj(MEM,INTERFACE,__VA_ARGS__) -#define _(METHOD,...) ((((_ARG1(__VA_ARGS__,)) || /* will not compile if object is not lvalue: */(_ARG1(__VA_ARGS__,)=NULL)) && (_ARG1(__VA_ARGS__,))->__interface->METHOD)?(*( (_ARG1(__VA_ARGS__,))->__interface->METHOD )) ((void *)__VA_ARGS__):0) -//#define __(METHOD,...) ( _ASSERT(ARG1(__VA_ARGS__,)), (*( __cll1_seekmethod(ARG1(__VA_ARGS__,),METHOD) )) ( __VA_ARGS__ ) ) -#define call(OBJTYPE,METHOD,...) { int _N=0; OBJTYPE _OBJ; /* <-' */ while( (_OBJ=(OBJTYPE)_cll1_for_ptrs(_N++,__VA_ARGS__,NIL))!=(OBJTYPE)NIL ) _(_OBJ,METHOD); } -#define def_community(TYPE,INTERFACE) def_obj(TYPE) { INTERFACE __interface; }; -/* ---- variable declarators -------------------------------------------- */ -#define Get_obj(ID,MEM,...) MEM ID=get_obj(MEM,__VA_ARGS__) -#define Get_obj_as(ID,COMMUNITY,MEM,...) MEM ID=get_obj_as(COMMUNITY,MEM,INTERFACE,__VA_ARGS__) -#define I_am(SELF,MEM) MEM SELF=(MEM)community -/* .----------------------------------------------------------------------. - / 9. C<<1 setjmp()/longjmp() based exceptions, updated 2008-09-30 - '----------------------------------------------------------------------- */ -#define FAILED_TO_FAIL -273 -#define SYSTEM_FAILURE -1 -#define LOCAL_FAILURE 13 -#define LIBRARY_FAILURE 23 -#define EVIL_FAILURE 666 -#define die(MSG) longjmp(_EENV,(errstr=MSG,LOCAL_FAILURE)) -#define try _NEW(E,0) if(!(_E=setjmp(_EENV))) -#define fail(E) longjmp(_EENV,((E)>0?(E):FAILED_TO_FAIL)) -#define pass_failure (_Eatom->__next?longjmp((pop(_Eatom,_Estack),_EENV),_E):_SYSFAIL(FAILED_TO_FAIL)) -#define else_switch_failures else switch(_E) -#define else_catch(E) else if (_E==(E)) -/* .----------------------------------------------------------------------. - / 10. implementation of C<<1 library functions, updated 2008-01-26 xCh. - '----------------------------------------------------------------------- */ -/* later... #define _MALLOC void *_cll1_malloc(size_t size) { return malloc(size); } */ -#define _CLL1_FPRINT(IOSTREAM) { int ofs=0; va_list ap; /* <-' */ for(va_start(ap,s);s!=NIL;s=va_arg(ap,char *)) { if(ofs)fputs(OFS,IOSTREAM);else ofs=1;/**/fputs(coalesce(s,NIL),IOSTREAM); } va_end(ap); fputs(EOL,IOSTREAM); } -#define _DECLARE_PRINT void _cll1_print(const char *s,...) -#define _PRINT _DECLARE_PRINT _CLL1_FPRINT(stdout) -#define _DECLARE_FPRINT void _cll1_fprint(FILE *f,const char *s,...) -#define _FPRINT _DECLARE_FPRINT _CLL1_FPRINT(f) -#define _CLL1_FECHO(IOSTREAM) { va_list ap; /* <-' */ for(va_start(ap,s);s!=NIL;s=va_arg(ap,char *)) fputs(coalesce(s,NIL),IOSTREAM); va_end(ap); } -#define _ECHO void _cll1_echo(char *s,...) _CLL1_FECHO(stdout) -#define _FECHO void _cll1_fecho(FILE *f,char *s,...) _CLL1_FECHO(f) -#define _FOR_INTS int _cll1_for_ints(int i, int n, ...) { int j=0;va_list ap; /* <-' */ va_start(ap,n); while(n!=WEIRDINT && j++I) -#define _J (_Iatom->J) -#define _S (_Satom->S) -#define _F (_Fatom->F) -#define _CTX (_CTXatom->CTX) -#define _E (_Eatom->E) -#define _EENV (_Eatom->ENV) -#define _ERRNO (_Eatom->ERRNO) -#define _ARG1(ARG1,...) ARG1 -//#define _ASSERT(EXPR) (expr?expr:fail(CONSISTENCY_FAILURE)) -#define _SYSFAIL(E) longjmp(_EENV,(_ERRNO=errno,(E))) -#define _GET_MEM(TYPE) ((TYPE)malloc(sizeof(struct _##TYPE##_struct))) /* later... ((TYPE)_cll1_malloc(sizeof(struct _##TYPE##_struct))) */ -#define _ANYATOM(NAME,DECL) def_mem(_##NAME##Atom ) { DECL; int c; list( _##NAME##Atom ); } -//#define _FOR_COLUMNS(A,B,C) _NEW(I,0) for( prefix(A,B,C) ; A ; ((A!=B)&&prefix(A,B,C)||(A=NULL) ),_I++ ) -//#define _FOR_VALID_COLUMNS(A,B,C) _NEW(I,0) for( prefix(A,B,C) ; A ; ((A!=B)&&prefix(A,B,C))||(A=NULL) ) if(*A&&++_I) -#define _NEW(NAME,VALUE) for(_##NAME##atom=get_mem(_##NAME##Atom),_##NAME##atom->NAME=(VALUE),_##NAME##atom->c=1,push(_##NAME##atom,_##NAME##stack);_##NAME##atom->c||(pop(_##NAME##atom,_##NAME##stack),0);_##NAME##atom->c--) -#define _ANYSTACK(NAME) extern _##NAME##Atom _##NAME##atom, _##NAME##stack; _##NAME##Atom _##NAME##atom,_##NAME##stack=NULL; -#define _EXPORT_STACKS _ANYSTACK(I) _ANYSTACK(S) _ANYSTACK(F) _ANYSTACK(CTX) _ANYSTACK(E) -_ANYATOM(I, int I;int J); -_ANYATOM(S, str S); -_ANYATOM(F, file F); -_ANYATOM(CTX, void *CTX); -_ANYATOM(E, int E;jmp_buf ENV;int ERRNO); -/* .----------------------------------------------------------------------. - / 11. C<<1 memory contexts - alternative to garbage collection - '----------------------------------------------------------------------- */ -typedef _CTXAtom * context; -#define create_context(ID) create_mem(ID,context) -/* .----------------------------------------------------------------------. - / 12. C<<1 CGI and FASTCGI handling, updated 2008-01-16 by xCh. - '----------------------------------------------------------------------- */ -#ifdef USE_LIBRARY_FASTCGI -#define while_fastcgi_accept while(FCGI_Accept()>=0) -#define USE_MODULE_CGI -#endif -#ifdef USE_MODULE_CGI -#define cgi(MIME) { char *PTR; /* <-' */ recycle_context(_CGI); _CGIdict=NULL; for_split_str(PTR,getenv("QUERY_STRING"),'&') /* _init_cgi */ if(MIME) printf("Content-type: %s\r\n\r\n",MIME); } -#define _GETCGI char *getcgi(VAR) { } -#define _CGI_GLOBALS def_context(_CGI); struct _CGIVariable { char *V; dict(_CGIVariable); } *_CGIvariable,*_CGIdict; -#else -#define _GETCGI -#define _CGI_GLOBALS -#endif -/* .----------------------------------------------------------------------. - / 13. MySQL wrappers + SQL object interface, updated 2007-12-19 by xCh. - '----------------------------------------------------------------------- */ -#ifdef USE_LIBRARY_MYSQL -#define def_sql(CONN) MYSQL *CONN -#define create_sql(CONN) MYSQL *ID=mysql_init(NULL) -#define sql_connect(CONN,S,U,P,D) mysql_real_connect(CONN,S,U,P,D,0,NULL,0) -//todo sql_query -//todo sql_queryf -//todo for_sql_query_results(ROW,CONN,QUERY) -//todo for_sql_queryf_results -#define if_db_connect(U,P,D) _NEW(SQLC,mysql_init(NULL)) for(;_SQLC && mysql_real_connect(_SQLC,"localhost",U,P,D,0,NULL,0);mysql_close(SQLC),SQLC=NULL) -#define for_db_query_results(ROW,QUERY) _NEW(MYSQLR,mysql_query(_MYSQLC,QUERY)) for( (_SQLR=(_MYSQLR?0:mysql_use_result(_MYSQLC))),(ROW=(_MYSQLR?mysql_fetch_row(_MYSQLR):NULL)) ; ROW ; ROW=mysql_fetch_row(_MYSQLR) ) -//todo db_query -//todo for_db_results -//todo for_db_queryf_results(ROW,...) -//todo db_queryf -#define _MYSQLC (_MYSQLCatom->MYSQLC) -#define _MYSQLR (_MYSQLRatom->MYSQLR) -#define _SQL_GLOBALS _ANYSTACK(MYSQL,MYSQLC) _ANYSTACK(MYSQL_RES,MYSQLR) -#else -#define _SQL_GLOBALS -#endif -//#ifdef USE_INTERFACE_SQL -//todo #define _SQL_OBJECT mem Sql { interface(SqlInterface); char *hostname; char *username; char *password; char *database; } -//todo #define _SQL_CONSTRUCT def_construct(Sql) { self->hostname="localhost"; } -//#endif - -/* ------------------------------------------------------------------- */ -/* old - from version 0.6 */ -/* =================================================================== */ -/* -obsolete -#define strlwr(A) {char *_S=A; while(_&&*_S){*_S=tolower(*_S);_S++;}} -#define strupr(A) {char *_S=A; while(_&&*_S){*_S=toupper(*_S);_S++;}} -#define string(S,L) (S=(char *)malloc(L),*S=0) -#define duplicate(A,B) if(A) { string(B,strlen(A)+1); strcpy(B,A); } -#define concatenate(A,B,C) if (A && B) { string(C,strlen(A)+strlen(B)+1); strcpy(C,A); strcat(C,B); } -#define gotoalpha(CHAR) if(CHAR)while(*CHAR && !isalpha(*CHAR))CHAR++ -#define goto_alpha(CHAR) if(CHAR)while(*CHAR && !isalpha(*CHAR) && *CHAR!='_')CHAR++ -#define gotoalnum(CHAR) if(CHAR)while(*CHAR && !isalnum(*CHAR))CHAR++ -#define goto_alnum(CHAR) if(CHAR)while(*CHAR && !isalnum(*CHAR) && *CHAR!='_')CHAR++ -#define skipalpha(CHAR) if(CHAR)while(*CHAR && isalpha(*CHAR))CHAR++ -#define skip_alpha(CHAR) if(CHAR)while(*CHAR && (isalpha(*CHAR) || *CHAR=='_'))CHAR++ -#define skipalnum(CHAR) if(CHAR)while(*CHAR && isalnum(*CHAR))CHAR++ -#define skip_alnum(CHAR) if(CHAR)while(*CHAR && (isalnum(*CHAR) || *CHAR=='_'))CHAR++ -#define skipspaces(CHAR) if(CHAR)while(*CHAR==' ')CHAR++ -#define cutspaces(CHAR) if(CHAR){int _L=strlen(CHAR); while(--_L>0 && CHAR[_L]==' ')CHAR[_L]=0;} -#define gotochr(CHAR,C) if(CHAR)while(*CHAR && *CHAR!=C)CHAR++ -#define strswitch(CHAR) {char *_K=CHAR; FILE *_F=NULL; {{ -#define stroption(STR) if(eq(STR,_K)) -#define match(KEY,VAL) {char *_K=KEY, *_V=VAL; FILE *_F=NULL; {{ -#define assign(STR,SETVAR) stroption(STR) SETVAR=_V -*/ -/* I/O iterations, updated 2004-04-19 by xCh. */ - -//#define fparse(S,L,F) for(fgets(S,L,F);*S && !feof(F);fgets(S,L,F)) -//#define input(S,L) fparse(S,L,stdin) -//#define fstring(S,F) { int _C=0,_L=0; fpos_t _P; fgetpos(F,&_P); while(_C!='\n' && !feof(F)){ _C=fgetc(F); _L++; } string(S,_L); fsetpos(F,&_P);fgets(S,_L,F);fgetc(F);} -//#define parses(S,F) {FILE *_F=fopen(F,"r"); if(_F) { while(!feof(_F)) { fstring(S,_F); -//obsolete -//#define parse(F) {char *_; FILE *_F=fopen(F,"r"); if(_F) { while(!feof(_F)) { fstring(_,_F); -//#define fail }} else {{ -//#define done }} if(_F)fclose(_F);} -//to do #define option(STR,SETVAR) if(_){char *_K,*_V,*_O,*_Q; duplicate(_,_Q); _O=_Q; tr(_O,'\t',' '); prefix(_K,_O,' '); if(eq(STR,_K)) {skipspaces(_O); prefix(_V,_O,'#'); cutspaces(_V); SETVAR=_V; _=NULL;} else free(_Q);} -//to do #define ioption(STR,SETVAR) if(_){char *_K,*_V,*_O,*_Q; duplicate(_,_Q); _O=_Q; tr(_O,'\t',' '); prefix(_K,_O,' '); if(eq(STR,_K)) {skipspaces(_O); prefix(_V,_O,'#'); cutspaces(_V); SETVAR=atoi(_V); _=NULL;} free(_Q);} -//to do #define loption(STR,SETVAR) if(_){char *_K,*_V,*_O,*_Q; duplicate(_,_Q); _O=_Q; tr(_O,'\t',' '); prefix(_K,_O,' '); if(eq(STR,_K)) {skipspaces(_O); prefix(_V,_O,'#'); cutspaces(_V); SETVAR=atol(_V); _=NULL;} free(_Q);} - -/* I/O sequences, updated 2003-05-29 by xCh. */ - -#define nullreopen(F) F=freopen("/dev/null","r",F) -#define stdinredir(CMD) {int _r[2];pipe(_r);if(fork()==0){dup2(_r[1],1);close(_r[0]);CMD;exit(0);}nullreopen(stdin);dup2(_r[0],0);close(_r[1]);} -#define shell(CMD) stdinredir(system(CMD)) -#define paste(STR) stdinredir(fputs(STR,stdout)) - -/* Useful structures, updated 2003-05-29 by xCh. */ - -//#define date(S) { time_t _T; _T=time(NULL); duplicate(ctime(&_T),S); } - -/* some general ideas, unfinished */ -//bind_exception, unbind_exception -//#define _CLL1_THROW(ERR) -//#define _CLL1_TRY _NEW_E for(bind_exception(0,NULL);;) if () {.... if(_Eatom->SYS) { if(_Eatom->RET) return; else break;} else { } - -/* .----------------------------------------------------------------------. - / 98. We have have done our homework - now let's have some fun: - '----------------------------------------------------------------------- */ -#define _INIT_VARIABLES _EXPORT_GLOBALS _EXPORT_YES _EXPORT_STACKS _SQL_GLOBALS _CGI_GLOBALS -#define _IMPL_FUNCTIONS /*_MALLOC*/ _EXPORT_OUTS _EXPORT_ARGS _EXPORT_STRS -#define _IMPL_INTERFACE //_SQL_IFC _CAKE_IFC _STD_IFC _X_IFC -#define _IMPLEMENT_CLL1_LIBRARY _INIT_VARIABLES _IMPL_FUNCTIONS _IMPL_INTERFACE -//this will be probably accomplished some other way... -#ifndef DISABLE_LIBRARY_CLL1 -_IMPLEMENT_CLL1_LIBRARY -#endif -#ifdef USE_LC_ALL -#define _UNSET_LC_NUMERIC setlocale(LC_NUMERIC, "C"); /* LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, LC_TIME */ -#else -#define _UNSET_LC_NUMERIC -#endif -#define _DECLARE_PROGRAM void _PROGRAM(int argc, char **argv) -#define _PROGRAM _cll1_program -#define program \ -_DECLARE_PROGRAM; \ -int main(int argc, char **argv) \ -{ \ - LANG=setlocale(LC_ALL, ""); \ - _UNSET_LC_NUMERIC \ - try \ - { \ - _PROGRAM(argc,argv); \ - return 0; \ - } \ - else_switch_failures \ - { \ - case SYSTEM_FAILURE: \ - errno=_ERRNO; \ - perror(errstr); /* and return -1 */ \ - default: \ - return -1; \ - } \ -} \ -_DECLARE_PROGRAM -#ifdef USE_PREPROCESSOR -#include "_include.c" -#endif -/* .----------------------------------------------------------------------. - / 99. C<<1 is up and running. It's your turn now to show something new. - '----------------------------------------------------------------------- */ -#endif diff --git a/demos/advanced-hello-world.c b/demos/advanced-hello-world.c deleted file mode 100644 index 124788a..0000000 --- a/demos/advanced-hello-world.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "cll1.h" - -program -{ - print("* echo()"); - echo("Hello"," ","world"," !\n"); - print("* print()"); - print("Hello","world","!"); - print("* NIL"); - print("We can print", NULL, "safely."); - NIL="(hic sunt crocodiles)"; - print("We can print", NULL, "safely."); - - { - str p = "print", a = NULL; - print("* coalesce():"); - print("We can", coalesce(p, "everything"), "almost", coalesce(a, "anything"), "safely."); - } - - echo("Surprisingly ->",NIL," (you can't see this)"); - print("<- nothing special here."); - print("* OFS"); - OFS=""; - EOL=""; - print("We","Can","Print","Without","Spaces","BetweenArgs."); - OFS=":"; - print("We","can","customize","print."); - OFS="..."; - EOL="<--\n"; - print(""); - print("* MAYBE ?"); - repeat(4) print((MAYBE ? "Hello" : "Hi"), (MAYBE ? "world" : "friend"), (MAYBE ? "!" : "?")); - print("* WHOKNOWS ?"); - repeat(4) print((WHOKNOWS ? "Hello" : "Hi"), (WHOKNOWS ? "world" : "friend"), (WHOKNOWS ? "!" : "?")); -} diff --git a/demos/ansi-c/float-list-plain-c.c b/demos/ansi-c/float-list-plain-c.c deleted file mode 100644 index 0501873..0000000 --- a/demos/ansi-c/float-list-plain-c.c +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include - - -struct Node -{ - float f; - struct Node* next; -}; - -void IterateList (struct Node* HeadList); -struct Node* makelist(struct Node** Head, struct Node** Tail); - -struct Node* makelist(struct Node** Head, struct Node** Tail) -{ - struct Node* new = (struct Node *)malloc(sizeof (struct Node)); - new->next = NULL; - - if (*Head == NULL) - { - *Head = new; - *Tail = *Head; - } - else - { - (*Tail)->next = new; - *Tail = new; - } - return (new); -} -void IterateList (struct Node* HeadList) -{ - struct Node* current = HeadList; - - while (current != NULL) - { - printf("The float you entered is %f\n",current->f); - current = current->next; - } -} -int main(void) -{ - struct Node* head = NULL; - struct Node* tail = NULL; - struct Node* curr = NULL; - int i; - - for(i=0; i < 20; i++) - { - /* create node */ - curr = makelist(&head,&tail); - printf("Enter float :\n"); - scanf("%f", &(curr->f)); - } - - /* now iterate the list */ - IterateList(head); - - return 0; -} diff --git a/demos/ansi-c/objects-c.c b/demos/ansi-c/objects-c.c deleted file mode 100644 index d75befb..0000000 --- a/demos/ansi-c/objects-c.c +++ /dev/null @@ -1,107 +0,0 @@ -#include -#include - -#define CONFEDERATION(IFACE,TYPE) struct IFACE *interface;struct TYPE *next -#define CREATE(TYPE) (struct TYPE *)malloc(sizeof(struct TYPE)) -#define APPEND(TYPE,MEMBER,LIST) (MEMBER?MEMBER->next=(struct TYPE *)LIST:0,LIST=(struct TYPE *)MEMBER) - -struct Drawable_data -{ - CONFEDERATION(Drawable_interface,Drawable_data); -}; - -struct Drawable_interface -{ - void (*draw)(void *self); -}; - -struct Tri -{ - CONFEDERATION(Drawable_interface,Drawable_data); - int x1; int y1; int x2; int y2; int x3; int y3; -}; - -struct Rect -{ - CONFEDERATION(Drawable_interface,Drawable_data); - int x1; int y1; int x2; int y2; -}; - -void draw_tri(void *_self) -{ - struct Tri *self=(struct Tri *)_self; - printf("%d,%d - %d,%d - %d,%d\n",self->x1,self->y1,self->x2,self->y2,self->x3,self->y3); -}; - -void draw_rect(void *self) -{ - struct Rect *r=(struct Rect *)self; - printf("%d,%d - %d,%d\n",r->x1,r->y1,r->x2,r->y2); -}; - -struct Drawable_interface *init_tri_interface(void) -{ - struct Drawable_interface *i=CREATE(Drawable_interface); - /* vsechny metody je bohuzel potreba bindnout rucne, neda se svitit... */ - if(i) i->draw=draw_tri; - return i; -} - -struct Drawable_interface *init_rect_interface(void) -{ - struct Drawable_interface *i=CREATE(Drawable_interface); - /* vsechny metody je bohuzel potreba bindnout rucne, neda se svitit... */ - if(i) i->draw=draw_rect; - return i; -} - -struct Tri *create_tri(struct Drawable_interface *i, int x1, int y1, int x2, int y2, int x3, int y3) -{ - struct Tri *t=CREATE(Tri); - if(i && t) - { - t->interface=i; - t->x1=x1;t->y1=y1;t->x2=x2;t->y2=y2;t->x3=x3;t->y3=y3; - } - return t; -} - -struct Rect *create_rect(struct Drawable_interface *i, int x1, int y1, int x2, int y2) -{ - struct Rect *r=CREATE(Rect); - if(i && r) - { - r->interface=i; - r->x1=x1;r->y1=y1;r->x2=x2;r->y2=y2; - } - return r; -} - -int main(void) -{ - struct Drawable_interface *tri_interface=init_tri_interface(); - struct Drawable_interface *rect_interface=init_rect_interface(); - struct Drawable_data *all=NULL,*one; - struct Tri *t; - struct Rect *r; - - r=create_rect(rect_interface,0,10,1,11); - APPEND(Drawable_data,r,all); - t=create_tri(tri_interface,0,0,0,4,3,0); - APPEND(Drawable_data,t,all); - r=create_rect(rect_interface,10,0,11,1); - APPEND(Drawable_data,r,all); - - /* a nyni ... bylo to hodne prace, ale povedlo se ... ! */ - - for(one=all;one;one=one->next) (*(one->interface->draw))(one); - - /* a nyni pro efekt jeste instatni nudlovy kod s kanci prichuti: */ - -#define _(OBJECT,METHOD) OBJECT==NULL)?0:(*(OBJECT->interface->METHOD))(OBJECT -#define FOR_EACH(ONE,ALL) for(ONE=ALL;ONE;ONE=ONE->next) - - FOR_EACH(one,all) (_(one,draw)); - - return 0; -} diff --git a/demos/ansi-c/objects-c99.c b/demos/ansi-c/objects-c99.c deleted file mode 100644 index f9884ff..0000000 --- a/demos/ansi-c/objects-c99.c +++ /dev/null @@ -1,134 +0,0 @@ -#include -#include -#include - -#define CONFEDERATION(IFACE,TYPE) struct IFACE *interface;struct TYPE *next -#define CREATE(TYPE) (struct TYPE *)malloc(sizeof(struct TYPE)) -#define APPEND(TYPE,MEMBER,LIST) (MEMBER?MEMBER->next=(struct TYPE *)LIST:0,LIST=(struct TYPE *)MEMBER) -#define SELF void *_self, void *_dummy -#define I_AM(TYPE) struct TYPE *self=(struct TYPE *)_self; - -struct Drawable_data -{ - CONFEDERATION(Drawable_interface,Drawable_data); -}; - -struct Drawable_interface -{ - void (*draw)(SELF); - int (*desc)(SELF, int something); -}; - -struct Tri -{ - CONFEDERATION(Drawable_interface,Drawable_data); - int x1; int y1; int x2; int y2; int x3; int y3; -}; - -struct Rect -{ - CONFEDERATION(Drawable_interface,Drawable_data); - int x1; int y1; int x2; int y2; -}; - -void draw_tri(SELF) -{ - I_AM(Tri); - printf("imagine I am drawing %d,%d - %d,%d - %d,%d\n",self->x1,self->y1,self->x2,self->y2,self->x3,self->y3); -}; - -void draw_rect(SELF) -{ - I_AM(Rect); - printf("imagine I am drawing %d,%d - %d,%d\n",self->x1,self->y1,self->x2,self->y2); -}; - -int desc_tri(SELF, int something) -{ - I_AM(Tri); - printf("I am triangle %d,%d - %d,%d - %d,%d, method draw called with argument: %d\n",self->x1,self->y1,self->x2,self->y2,self->x3,self->y3, something); - return something; -}; - -int desc_rect(SELF, int something) -{ - I_AM(Rect); - printf("I am rectangle %d,%d - %d,%d, method draw called with argument: %d\n",self->x1,self->y1,self->x2,self->y2, something); - return something; -}; - -struct Drawable_interface *init_tri_interface(void) -{ - struct Drawable_interface *i=CREATE(Drawable_interface); - /* vsechny metody je bohuzel potreba bindnout rucne, neda se svitit... */ - if(i) { i->draw=draw_tri; i->desc=desc_tri; } - return i; -} - -struct Drawable_interface *init_rect_interface(void) -{ - struct Drawable_interface *i=CREATE(Drawable_interface); - /* vsechny metody je bohuzel potreba bindnout rucne, neda se svitit... */ - if(i) { i->draw=draw_rect; i->desc=desc_rect; } - return i; -} - -struct Tri *create_tri(struct Drawable_interface *i, int x1, int y1, int x2, int y2, int x3, int y3) -{ - struct Tri *t=CREATE(Tri); - if(i && t) - { - t->interface=i; - t->x1=x1;t->y1=y1;t->x2=x2;t->y2=y2;t->x3=x3;t->y3=y3; - } - return t; -} - -struct Rect *create_rect(struct Drawable_interface *i, int x1, int y1, int x2, int y2) -{ - struct Rect *r=CREATE(Rect); - if(i && r) - { - r->interface=i; - r->x1=x1;r->y1=y1;r->x2=x2;r->y2=y2; - } - return r; -} - -int main(void) -{ - struct Drawable_interface *tri_interface=init_tri_interface(); - struct Drawable_interface *rect_interface=init_rect_interface(); - struct Drawable_data *all=NULL,*one; - struct Tri *t; - struct Rect *r; - - r=create_rect(rect_interface,0,10,1,11); - APPEND(Drawable_data,r,all); - t=create_tri(tri_interface,0,0,0,4,3,0); - APPEND(Drawable_data,t,all); - r=create_rect(rect_interface,10,0,11,1); - APPEND(Drawable_data,r,all); - - /* a nyni ... bylo to hodne prace, ale povedlo se ... ! */ - - for(one=all;one;one=one->next) - { - printf("(return value %d)\n",(*(one->interface->desc)) (one,NULL,0)); - (*(one->interface->draw)) (one,NULL); - } - - /* ...a nakonec pro efekt jeste instatni nudlovy kod s kanci prichuti dle ANSI C99: */ - -#define _ARG1(ARG1,...) ARG1 -#define _(OBJECT,...) (assert(OBJECT),/**/(*(OBJECT->interface->_ARG1(__VA_ARGS__,)))/**/(OBJECT,OBJECT->interface->__VA_ARGS__)/**/) -#define FOR_EACH(ONE,ALL) for(ONE=ALL;ONE;ONE=ONE->next) - - FOR_EACH(one,all) - { - printf("(return value %d)\n",_(one,desc,1)); - _(one,draw); - } - - return 0; -} diff --git a/demos/ansi-c/print-c99.c b/demos/ansi-c/print-c99.c deleted file mode 100644 index 7abbb16..0000000 --- a/demos/ansi-c/print-c99.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - -void _echo(char *s, ... ) { va_list ap; for(va_start(ap,s);s;s=va_arg(ap,char *)) fputs(s,stdout); va_end(ap); } -#define print(...) _echo(__VA_ARGS__,"\n",NULL) -#define echo(...) _echo(__VA_ARGS__,NULL) - -int main(void) -{ - echo("Hello ","world","! "); - print("Hello ","world","! "); -} diff --git a/demos/arguments1.c b/demos/arguments1.c deleted file mode 100644 index 552e983..0000000 --- a/demos/arguments1.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "cll1.h" - -/* try to run: ./arguments1 -x xxx yyyy -c cccc */ - -program -{ - if_args - { - for_args - { - if this_arg[0] == '-') - { - printf("Command line switch: -%c ",ptr[1]); - if (next_arg) then - { - echo("followed by: ",next_arg); - skip_next; - } - print(""); - } - else - print("Standalone argument: ",ptr); - } - } - else - print("Bleeeeh, no arguments supplied... :-("); -} diff --git a/demos/arguments2.c b/demos/arguments2.c deleted file mode 100644 index 63276cf..0000000 --- a/demos/arguments2.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "cll1.h" - -//try to run: ./arguments2 -f reload yyyy -? - -program -{ - if_args then - { - for_args - { - if_arg ("-?") then - print("This is just help!"); - else if_arg ("-f") then - { - if (next_arg) then - { - print("Forced argument: ",next_arg); - skip_one; - } - } - else - print("Normal argument: ",this_arg); - } - } - else - print("Bleeeeh, no arguments supplied... :-("); -} diff --git a/demos/boolean.c b/demos/boolean.c deleted file mode 100644 index 77d1967..0000000 --- a/demos/boolean.c +++ /dev/null @@ -1,22 +0,0 @@ -#include "cll1.h" - -program -{ - const bool t = TRUE, f = FALSE; - bool l, m = MAYBE; - str s; - - print("TRUE and FALSE =", btoa(t and f) ); - print("TRUE or FALSE =", btoa(t or f) ); - print("TRUE and MAYBE =", btoa(t and m) ); - print("FALSE or MAYBE =", btoa(t or m) ); - print("not FALSE =", btoa(not f) ); - print("not TRUE =", btoa(not t) ); - print("not MAYBE =", btoa(not m) ); - - for_strs(s, "TRUE","false","yes","NO","True","FALSE","YES","no","Yes","No","1","0","abc","xyz","Eyes","Ears","rue","alse","oui","no","ano","ne"," ","NULL",NULL,EOL,"","ano","ne") - { - l = atob(s); - echo("\"", s, "\"\tmeans ", btoa(l), EOL); - } -} diff --git a/demos/cll1.h b/demos/cll1.h deleted file mode 120000 index a4cde1a..0000000 --- a/demos/cll1.h +++ /dev/null @@ -1 +0,0 @@ -../cll1.h \ No newline at end of file diff --git a/demos/column.c b/demos/column.c deleted file mode 100644 index 764c635..0000000 --- a/demos/column.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "cll1.h" - -program -{ - char *ptr; - parse("/etc/passwd") - { - column(ptr,_,':',6); - if(ptr)puts(ptr); - } - done; -} diff --git a/demos/columns.c b/demos/columns.c deleted file mode 100644 index 9c6d9ce..0000000 --- a/demos/columns.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "cll1.h" - -program -{ - char *ptr; - int i; - parse("/etc/passwd") - { - columns(ptr,_,':',i) switch(i) - { - case 0: printf("%s...",ptr); break; - case 6: puts(ptr); - } - } - done; -} diff --git a/demos/eq.c b/demos/eq.c deleted file mode 100644 index d3a87ca..0000000 --- a/demos/eq.c +++ /dev/null @@ -1,49 +0,0 @@ -#include "cll1.h" - -program -{ - str a,b; - - print("Local language (enviroment) is set to:", LANG); - a="¾luklý"; - b="®LUKLÝ"; - printf("str_order(\"%s\",\"%s\") = %d\n",a,b,str_order(a,b)); - printf("eq(\"%s\",\"%s\") = %s\n",a,b,btoa(eq(a,b))); - printf("eq(\"%s\",\"%s\") = %s\n",a,a,btoa(eq(a,a))); - printf("eqi(\"%s\",\"%s\") = %s\n",a,b,btoa(eqi(a,b))); - a="aabc"; - b="axyz"; - printf("str_order(\"%s\",\"%s\") = %d\n",a,b,str_order(a,b)); - printf("eq(\"%s\",\"%s\") = %s\n",a,b,btoa(eq(a,b))); - printf("eqi(\"%s\",\"%s\") = %s\n",a,b,btoa(eqi(a,b))); - a="ABC"; - b="abc"; - printf("str_order(\"%s\",\"%s\") = %d\n",a,b,str_order(a,b)); - printf("eq(\"%s\",\"%s\") = %s\n",a,b,btoa(eq(a,b))); - printf("eqi(\"%s\",\"%s\") = %s\n",a,b,btoa(eqi(a,b))); - a="abc"; - b="abc"; - printf("str_order(\"%s\",\"%s\") = %d\n",a,b,str_order(a,b)); - printf("eq(\"%s\",\"%s\") = %s\n",a,b,btoa(eq(a,b))); - printf("eqi(\"%s\",\"%s\") = %s\n",a,b,btoa(eqi(a,b))); - a=""; - b=""; - printf("str_order(\"%s\",\"%s\") = %d\n",a,b,str_order(a,b)); - printf("eq(\"%s\",\"%s\") = %s\n",a,b,btoa(eq(a,b))); - printf("eqi(\"%s\",\"%s\") = %s\n",a,b,btoa(eqi(a,b))); - a=NULL; - b="abc"; - printf("str_order( %s ,\"%s\") = %d\n",a,b,str_order(a,b)); - printf("eq( %s ,\"%s\") = %s\n",a,b,btoa(eq(a,b))); - printf("eqi( %s ,\"%s\") = %s\n",a,b,btoa(eqi(a,b))); - a=NULL; - b=""; - printf("str_order( %s ,\"%s\") = %d\n",a,b,str_order(a,b)); - printf("eq( %s ,\"%s\") = %s\n",a,b,btoa(eq(a,b))); - printf("eqi( %s ,\"%s\") = %s\n",a,b,btoa(eqi(a,b))); - a=NULL; - b=NULL; - printf("str_order( %s , %s ) = %d\n",a,b,str_order(a,b)); - printf("eq( %s ,%s ) = %s\n",a,b,btoa(eq(a,b))); - printf("eqi( %s , %s ) = %s\n",a,b,btoa(eqi(a,b))); -} diff --git a/demos/exceptions/advanced-failures.c b/demos/exceptions/advanced-failures.c deleted file mode 100644 index 1f1f674..0000000 --- a/demos/exceptions/advanced-failures.c +++ /dev/null @@ -1,66 +0,0 @@ -#include "cll1.h" - -void private_method(int i) -{ - if(i==2) - { - fail(LOCAL_FAILURE); - } - else if(i==6) - { - fail(EVIL_FAILURE); - } - else - { - printf("nuda #%d\n",i); - } -} - -void some_job(int i) -{ - try - { - private_method(i); - private_method(i+1); - private_method(i+2); - } - else_switch_failures - { - case EVIL_FAILURE: puts("[serious error]"); pass_failure; - case LOCAL_FAILURE: puts("[non-fatal error detected]"); break; - default : puts("[sorry, vole, error]"); - } -} - -program -{ - - try - { - some_job(1); - some_job(3); - some_job(6); - some_job(2); - some_job(7); - } - else - { - puts("sorry, vole, error!"); - } - - try - { - some_job(1); - some_job(2); - some_job(4); - some_job(7); - } - else_catch(EVIL_FAILURE) - { - puts("totaly screwed."); - } - else - { - puts("ahem... something went wrong."); - } -} diff --git a/demos/exceptions/failures.c b/demos/exceptions/failures.c deleted file mode 100644 index 2338f7f..0000000 --- a/demos/exceptions/failures.c +++ /dev/null @@ -1,75 +0,0 @@ -#include "cll1.h" - -void some_function(int i) -{ - if(i==2) - { - fail(EVIL_FAILURE); - } - if(i==7) - { - some_function(2); - } - if(i==6) - { - fail(LOCAL_FAILURE); - } - printf("nuda #%d\n",i); -} - -program -{ - try - { - some_function(1); - some_function(2); - some_function(6); - } - else_switch_failures - { - case EVIL_FAILURE: puts("serious failure detected!"); break; - default: puts("sorry, vole, error!"); - } - - try - { - some_function(1); - some_function(3); - some_function(6); - some_function(2); - } - else - { - puts("sorry, vole, error!"); - } - - try - { - some_function(1); - some_function(6); - } - else_catch(EVIL_FAILURE) - { - puts("Totally screwed."); - exit(-1); - } - else - { - puts("We survived this failure."); - } - - try - { - some_function(3); - some_function(7); - } - else_catch(EVIL_FAILURE) - { - puts("totally screwed."); - exit(-1); - } - else - { - puts("we survived this failure."); - } -} diff --git a/demos/fastcgi/fastcgi.c b/demos/fastcgi/fastcgi.c deleted file mode 100644 index 2d141d8..0000000 --- a/demos/fastcgi/fastcgi.c +++ /dev/null @@ -1,16 +0,0 @@ -#define USE_LIBRARY_FASTCGI -#include "cll1.h" - -program -{ - int count = 0; - while_fastcgi_accept - { - printf("Content-type: text/html\r\n" - "\r\n" - "FastCGI Hello!" - "

FastCGI Hello!

" - "Request number %d running on host %s\n", - ++count, getenv("SERVER_NAME")); - } -} diff --git a/demos/for_ints_strs.c b/demos/for_ints_strs.c deleted file mode 100644 index dbcc3d7..0000000 --- a/demos/for_ints_strs.c +++ /dev/null @@ -1,15 +0,0 @@ -#include "cll1.h" - -program -{ - int i; - str s; - - echo("for_ints(i, 8,1,-2,745,-32,-64,27,4) ): "); - for_ints(i, 8,1,-2,745,-32,-64,27,4 ) printf(" [%d]",i); - print(""); - - echo("for_strs(s, \"aasd\",\"snres\",\"sdfrm\",\"ojffgt\",\"wweqwe\" )): "); - for_strs(s, "aasd","snres","sdfrm","ojffgt","wweqwe" ) echo(" [",s,"]"); - print(""); -} diff --git a/demos/for_range.c b/demos/for_range.c deleted file mode 100644 index c96f24c..0000000 --- a/demos/for_range.c +++ /dev/null @@ -1,51 +0,0 @@ -#include "cll1.h" - -program -{ - int i,j=1; - - echo("Just plain vanilla auto-increment:\tfor_range(i,1,5)"); - for_range(i,1,5) - { - printf(" [%d]",i); - } - print(""); - - echo("Single-evaluation of macro argument:\tj=1; for_range(i,0,j++)"); - for_range(i,0,j++) - { - printf(" [%d]",i); - } - print(""); - - echo("Just plain vanilla auto-decrement:\tfor_range(i,1,0)"); - for_range(i,1,0) - { - printf(" [%d]",i); - } - print(""); - - echo("Single iteration is possible too:\tfor_range(i,1,1)"); - for_range(i,1,1) - { - printf(" [%d]",i); - } - print(""); - - echo("Yet another example of macro safety:\tj=2; for_range(i,5,--j)"); - for_range(i,5,--j) - { - printf(" [%d]",i); - } - print(""); - - echo("Nesting of this macro seems to be safe:\tfor_range(i,1,3) for_range(j,3,1)"); - for_range(i,1,3) - { - for_range(j,3,1) - { - printf(" [%d,%d]",i,j); - } - } - print(""); -} diff --git a/demos/hello.c b/demos/hello.c deleted file mode 100644 index be92852..0000000 --- a/demos/hello.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "cll1.h" - -program -{ - print("Vale Mundum!"); -} diff --git a/demos/idmap.c b/demos/idmap.c deleted file mode 100644 index ff96319..0000000 --- a/demos/idmap.c +++ /dev/null @@ -1,94 +0,0 @@ -#include "cll1.h" - -struct Line -{ - int n; - list(Line); -} *line; - -struct Id -{ - char *str; - int count; - struct Line *lines; - list(Id); -} *id,*ids=NULL; - -program -{ - char *ptr; - char *fname; - char *c=NULL; - int l=0; - - arguments - { - thisargument(fname); - nextargument(c); - } - else - { - puts("Usage: idmap file [c]"); - return 1; - } - - parse(fname) - { - l++; - while(*_) - { - goto_alpha(_); - ptr=_; - skip_alnum(_); - *_=0; - _++; - - if(*ptr) - { - if_exists(id,ids,eq(id->str,ptr)) - { - id->count++; - if_exists(line,id->lines,line->n==l); - else - { - create(line,Line); - line->n=l; - push(line,id->lines); - } - } - else - { - create(id,Id); - create(line,Line); - id->str=ptr; - id->count=1; - id->lines=line; - line->n=l; - insert(id,ids,sort_by,str); - } - } - if(*_=='"' || *_=='\'' ) - { - char c=*_; - _++; - gotochr(_,c); - } - } - } - fail - { - perror(argv[1]); - exit(-1); - } - done; - - if(c) - sort(id,ids,desc_order_by,count); - - for_each(id,ids) - { - printf("%3dx %s",id->count,id->str); - for_each(line,id->lines) printf(" [%d]",line->n); - printf("\n"); - } -} diff --git a/demos/lists/cll1.h b/demos/lists/cll1.h deleted file mode 120000 index a4cde1a..0000000 --- a/demos/lists/cll1.h +++ /dev/null @@ -1 +0,0 @@ -../cll1.h \ No newline at end of file diff --git a/demos/lists/float-list-ordered.c b/demos/lists/float-list-ordered.c deleted file mode 100644 index a9c996f..0000000 --- a/demos/lists/float-list-ordered.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "cll1.h" - -def_mem(Node) -{ - float f; - list(Node); -}; - -program -{ - Node one,all=NULL; - - repeat(20) - { - one=get_mem(Node); - printf("Enter float: \n"); - scanf("%f", &(one->f)); - insert(one,all,order_by_num,f); - } - - for_each(one,all) - { - printf("The float you entered is %f\n",one->f); - } -} diff --git a/demos/lists/float-list-plain.c b/demos/lists/float-list-plain.c deleted file mode 100644 index 808303f..0000000 --- a/demos/lists/float-list-plain.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "cll1.h" - -def_mem(Node) -{ - float f; - list(Node); -}; - -program -{ - Node one,all=NULL,last=NULL; - - repeat(20) - { - one=get_mem(Node); - printf("Enter float: \n"); - scanf("%f", &(one->f)); - append(one,last); - if(not all) - { - all=last; - } - } - - for_each(one,all) - { - printf("The float you entered is %f\n",one->f); - } -} diff --git a/demos/lists/lists.c b/demos/lists/lists.c deleted file mode 100644 index 9af730e..0000000 --- a/demos/lists/lists.c +++ /dev/null @@ -1,95 +0,0 @@ -#include "cll1.h" - -def_mem(Record) -{ - int i; - str s; - list(Record); -}; - -program -{ - Record record, records = NULL; - - print("4x insert(record,records,order_by_num,i);"); - - record = get_mem(Record); - record->i = 1; - record->s = "ddd"; - insert(record, records, order_by_num, i); - - record = get_mem(Record); - record->i = 3; - record->s = "BBBB"; - insert(record, records, order_by_num, i); - - record = get_mem(Record); - record->i = 4; - record->s = "e"; - insert(record, records, order_by_num, i); - - record = get_mem(Record); - record->i = 2; - record->s = "aaaa"; - insert(record, records, order_by_num, i); - - for_each(record, records) - { - printf("i=%d, s=%s\n", record->i, record->s); - } - - print("1x append(record,records);"); - - record = get_mem(Record); - record->i = 0; - record->s = "ccc"; - append(record, records); - - for_each(record, records) - { - printf("i=%d, s=%s\n", record->i, record->s); - } - - print("sort(record,records,order_by_num_desc,i);"); - - sort(record, records, order_by_num_desc, i); - - for_each(record, records) - { - printf("i=%d, s=%s\n", record->i, record->s); - } - - print("sort(record,records,order_by_str,s);"); - - sort(record, records, order_by_str, s); - - for_each(record, records) - { - printf("i=%d, s=%s\n",record->i,record->s); - } - - print("sort(record, records, order_by_ascii_desc, s);"); - - sort(record, records, order_by_ascii_desc, s); - - for_each(record,records) - { - printf("i=%d, s=%s\n", record->i, record->s); - } - - print("remove(record,records,record->i==1);"); - remove(record, records, record->i == 1); - - for_each(record,records) - { - printf("i=%d, s=%s\n", record->i, record->s); - } - - print("drop(record,records);"); - drop(record, records); - - for_each(record, records) - { - printf("i=%d, s=%s\n", record->i, record->s); - } -} diff --git a/demos/locale.c b/demos/locale.c deleted file mode 100644 index 0f7d5af..0000000 --- a/demos/locale.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "cll1.h" - -program -{ - str a,b; - time_t t = time(NULL); - file f; - str filename = "blabla.txt"; - - print("Local language (enviroment) is set to:", LANG); - print("C<<1 automatically activates locales LC_COLLATE|LC_CTYPE|LC_MESSAGES|LC_MONETARY|LC_TIME but not LC_NUMERIC:"); - a = "¾luklý kùò"; - b = "®LUKLÝ KÙÒ"; - printf("str_order(\"%s\",\"%s\") = %d\n",a,b,str_order(a,b)); - printf("eq(\"%s\",\"%s\") = %s\n",a,b,btoa(eq(a,b))); - printf("eq(\"%s\",\"%s\") = %s\n",a,a,btoa(eq(a,a))); - printf("eqi(\"%s\",\"%s\") = %s\n",a,b,btoa(eqi(a,b))); - printf("PI will be displayed as: %f\n",PI); - echo("Time will be displayed as: ", ctime(&t)); - print("Error mesages will be displayed as: "); - f = fopen(filename,"r"); - if(not f) - { - errstr = filename; - _SYSFAIL(SYSTEM_FAILURE); - } -} diff --git a/demos/mysql/mysql.c b/demos/mysql/mysql.c deleted file mode 100644 index b314bbf..0000000 --- a/demos/mysql/mysql.c +++ /dev/null @@ -1,15 +0,0 @@ -#define USE_LIBRARY_MYSQL -#include "cll1.h" - -program -{ - MYSQL_ROW row; - - if(mysql_connect("localhost","root","","pokus")) - { - for_mysql_query_results(row,"SELECT id,str FROM pokus") - printf("id=%s str=%s\n", row[0], row[1]); - } - else - puts("Can't connect to database!"); -} diff --git a/demos/objects/objects-community.c b/demos/objects/objects-community.c deleted file mode 100644 index 0854766..0000000 --- a/demos/objects/objects-community.c +++ /dev/null @@ -1,315 +0,0 @@ -#include "cll1.h" - -/* This is example of advanced C<<1 object oriented features... */ - -def_interface(Shape, Interface) -{ - void method(draw) (Shape self); - void method(move) (Shape self, int x, int y); - str method(desc) (Shape self); - void method(rename) (Shape self, str name); - void method(reset) (Shape self, int x1, int y1, int x2, int y2, int x3, int y3); - float method(area) (Shape self); - int count; -}; - -/* We intentionaly define heterogenous objects, which share only the interface - binding. Not only we can use different order of variables, and different - names - but we can even store these data on remote systems, etc. */ - -def_mem(Tri) -{ - interface(Interface); - int x1, y1, x2, y2, x3, y3; - str name; -}; - -def_mem(Rect) -{ - interface(Interface); - str desc; - int x1, y1, x2, y2; -}; - -def_mem(Circ) -{ - interface(Interface); - int x1, y1; - str comment; - int r; -}; - -def_community(Shape, Interface); - -/* Note: interface(Interface); has to be at first position in all objects asociated in community */ - -def_mem(Object_list) -{ - Shape object; - list(Object_list); -}; - - -/* implementation of methods */ - -void drawTri(Shape community) -{ - I_am(self, Tri); - - printf("Drawing %s: %d,%d - %d,%d - %d,%d .\n", - self->name, self->x1, self->y1, self->x2, self->y2, self->x3, self->y3); -}; - -void drawRect(Shape community) -{ - I_am(self, Rect); - - printf("Drawing %s: %d,%d - %d,%d .\n", - self->desc, self->x1, self->y1, self->x2, self->y2); -}; - -void drawCirc(Shape community) -{ - I_am(self, Circ); - - printf("Drawing %s: %d,%d - r=%d .\n", - self->comment, self->x1, self->y1, self->r); -}; - -void moveTri(Shape community, int x, int y) -{ - I_am(self, Tri); - - self->x1 += x; - self->y1 += y; - self->x2 += x; - self->y2 += y; - self->x3 += x; - self->y3 += y; -}; - -void moveRect(Shape community, int x, int y) -{ - I_am(self, Rect); - - self->x1 += x; - self->y1 += y; - self->x2 += x; - self->y2 += y; -}; - -void moveCirc(Shape community, int x, int y) -{ - I_am(self, Circ); - - self->x1 += x; - self->y1 += y; -}; - -str descTri(Shape community) -{ - I_am(self, Tri); - - return self->name; -} - -str descRect(Shape community) -{ - I_am(self, Rect); - - return self->desc; -} - -str descCirc(Shape community) -{ - I_am(self, Circ); - - return self->comment; -} - -float calcAreaTri(Shape community) -{ - I_am(self, Tri); - - return 0; -} - -float calcAreaRect(Shape community) -{ - I_am(self, Rect); - - return (self->x2 - self->x1)*(self->y2 - self->y1); -} - -float calcAreaCirc(Shape community) -{ - I_am(self, Circ); - - return PI * self->r * self->r; -} - -void setTri(Shape community, int x1, int y1, int x2, int y2, int x3, int y3) -{ - I_am(self, Tri); - - self->x1 = x1; - self->y1 = y1; - self->x2 = x2; - self->y2 = y2; - self->x3 = x3; - self->y3 = y3; -} - -void setRect(Shape community, int x1, int y1, int x2, int y2, int dummy1, int dummy2) -{ - I_am(self, Rect); - - self->x1 = x1; - self->y1 = y1; - self->x2 = x2; - self->y2 = y2; -} - -void setCirc(Shape community, int x1, int y1, int r, int dummy1, int dummy2, int dummy3) -{ - I_am(self, Circ); - - self->x1 = x1; - self->y1 = y1; - self->r = r; -} - -void nameRect(Shape community, str name) -{ - I_am(self, Rect); - - self->desc = name; -} - -/* Example of using object interface methods from inside constructor methods */ - -construct(Tri,Interface) (Tri self, int x1, int y1, int x2, int y2, int x3, int y3) -{ - self->name = "TRIANGLE"; - interface_of(self)->count++; - _(reset, self, x1, y1, x2, y2, x3, y3); - - return self; -} - -construct(Rect,Interface) (Rect self, int x1, int y1, int x2, int y2) -{ - self->desc = "rectangle"; - interface_of(self)->count++; - _(reset, self, x1, y1, x2, y2, 0, 0); - - return self; -} - -construct(Circ,Interface) (Circ self, int x1, int y1, int r) -{ - self->comment = "Circle"; - interface_of(self)->count++; - _(reset, self, x1, y1, r, 0, 0, 0); - - return self; -} - -/* registration of implemented methods to three interfaces of the same type */ - -Interface triInterface(void) -{ - Get_mem(this, Interface); - - this->draw = drawTri; - this->move = moveTri; - this->desc = descTri; - this->rename = NULL; - this->reset = setTri; - this->area = calcAreaTri; - this->count = 0; - - return this; -} - -Interface rectInterface(void) -{ - Get_mem(this, Interface); - - this->draw = drawRect; - this->move = moveRect; - this->desc = descRect; - this->rename = nameRect; - this->reset = setRect; - this->area = calcAreaRect; - this->count = 0; - - return this; -} - -Interface circInterface(void) -{ - Get_mem(this, Interface); - - this->draw = drawCirc; - this->move = moveCirc; - this->desc = descCirc; - this->rename = NULL; - this->reset = setCirc; - this->area = calcAreaCirc; - this->count = 0; - - return this; -} - -/* usage of object community inside C<<1 program */ - -program -{ - Interface triangles = triInterface(); - Interface rectangles = rectInterface(); - Interface circles = circInterface(); - Object_list all = NULL, one; - - one = get_mem(Object_list); - one->object = get_obj_as(Shape, Rect, rectangles, 0, 10, 1, 11); - append(one, all); - - one = get_mem(Object_list); - one->object = get_obj_as(Shape, Tri, triangles, 0, 0, 0, 4, 3, 0); - append(one, all); - - one = get_mem(Object_list); - one->object = get_obj_as(Shape, Rect, rectangles, 10, 0, 11, 1); - append(one, all); - - one = get_mem(Object_list); - one->object = get_obj_as(Shape, Circ, circles, 0, 10, 1); - append(one, all); - - printf("We have created %d triangles, %d rectangles and %d circles:\n", - triangles->count, rectangles->count, circles->count); - - for_each(one, all) - { - _(draw, one->object); - printf("Area of this %s is %f (square pixels).\n", _(desc, one->object), _(area, one->object)); - printf("We have created %d instances of this type of object.\n", interface_of(one->object)->count); - - if(interface_of(one->object) == rectangles) - { - _(reset, one->object, 0, 0, 1, 1, 0, 0); - _(rename, one->object, "Renamed rectangle"); - } - else - { - _(move, one->object, 10, 10); - } - } - - print("Rectangles were reset to new size and renamed, other objects were moved:"); - for_each(one, all) - { - _(draw, one->object); - } -} diff --git a/demos/objects/objects-federation.c b/demos/objects/objects-federation.c deleted file mode 100644 index 5aeab79..0000000 --- a/demos/objects/objects-federation.c +++ /dev/null @@ -1,342 +0,0 @@ -#include "cll1.h" - -/* This is example of advanced C<<1 object oriented features... */ - -def_interface(Point, PointInterface) -{ - void method(move) (Shape self, int x, int y); - str method(desc) (Shape self); - void method(rename) (Shape self, str name); - int count; -}; - -def_interface(Shape, ShapeInterface) -{ - federation(Point); - void method(draw) (Shape self); - void method(reset) (Shape self, int x1, int y1, int x2, int y2, int x3, int y3); - float method(area) (Shape self); - int count; -}; - -/* This is example of non-hierarchical object federation architecture in C<<1 */ - -def_obj(Point) -{ - interface(PointInterface); - shape Shape; /* this is optional, but we will use it do demonstrate power of C<<1 */ - int x1, y1; - str desc; -} - -def_mem(Tri) -{ - interface(ShapeInterface); - Point point; - int x2, y2, x3, y3; -}; - -def_mem(Rect) -{ - interface(ShapeInterface); - Point point; - int x2, y2; -}; - -def_mem(Circ) -{ - interface(ShapeInterface); - Point point; - int r; -}; - -def_community(Shape, ShapeInterface); - -/* Note: interface(ShapeInterface); has to be at first position in all objects asociated in community */ - -def_mem(Object_list) -{ - Shape object; - list(Object_list); -}; - -/* implementation of methods */ - -void drawTri(Shape community) -{ - I_am(self, Tri); - - printf("Drawing %s: %d,%d - %d,%d - %d,%d .\n", - self->point->desc, self->point->x, self->point->y, self->x2, self->y2, self->x3, self->y3); -}; - -void drawRect(Shape community) -{ - I_am(self, Rect); - - printf("Drawing %s: %d,%d - %d,%d .\n", - self->point->desc, self->x1, self->y1, self->x2, self->y2); -}; - -void drawCirc(Shape community) -{ - I_am(self, Circ); - - printf("Drawing %s: %d,%d - r=%d .\n", - self->comment, self->x1, self->y1, self->r); -}; - -void moveTri(Shape community, int x, int y) -{ - I_am(self, Tri); - - self->x1 += x; - self->y1 += y; - self->x2 += x; - self->y2 += y; - self->x3 += x; - self->y3 += y; -}; - -void moveRect(Shape community, int x, int y) -{ - I_am(self, Rect); - - self->x1 += x; - self->y1 += y; - self->x2 += x; - self->y2 += y; -}; - -void moveCirc(Shape community, int x, int y) -{ - I_am(self, Circ); - - self->x1 += x; - self->y1 += y; -}; - -str descTri(Shape community) -{ - I_am(self, Tri); - - return _(desc, self->point); -} - -str descRect(Shape community) -{ - I_am(self, Rect); - - return _(desc, self->point); -} - -str descCirc(Shape community) -{ - I_am(self, Circ); - - return _(desc, self->point); -} - -float calcAreaTri(Shape community) -{ - I_am(self, Tri); - - return 0; -} - -float calcAreaRect(Shape community) -{ - I_am(self, Rect); - - return (self->x2 - self->x1)*(self->y2 - self->y1); -} - -float calcAreaCirc(Shape community) -{ - I_am(self, Circ); - - return PI * self->r * self->r; -} - -void setTri(Shape community, int x1, int y1, int x2, int y2, int x3, int y3) -{ - I_am(self, Tri); - - self->x1 = x1; - self->y1 = y1; - self->x2 = x2; - self->y2 = y2; - self->x3 = x3; - self->y3 = y3; -} - -void setRect(Shape community, int x1, int y1, int x2, int y2, int dummy1, int dummy2) -{ - I_am(self, Rect); - - self->x1 = x1; - self->y1 = y1; - self->x2 = x2; - self->y2 = y2; -} - -void setCirc(Shape community, int x1, int y1, int r, int dummy1, int dummy2, int dummy3) -{ - I_am(self, Circ); - - self->x1 = x1; - self->y1 = y1; - self->r = r; -} - -void nameRect(Shape community, str newname) -{ - I_am(self, Rect); - - _(name, self->point, newname); -} - -/* Example of using object interface methods from inside constructor methods */ - -construct(Tri,ShapeInterface) (Tri self, int x1, int y1, int x2, int y2, int x3, int y3) -{ - self->point = get_federation(Point); - _(move, self->point, x1, x2); - self->name = "TRIANGLE"; - interface_of(self)->count++; - _(reset, self, x2, y2, x3, y3); - - return self; -} - -construct(Rect,ShapeInterface) (Rect self, int x1, int y1, int x2, int y2) -{ - self->desc = "rectangle"; - interface_of(self)->count++; - _(reset, self, x1, y1, x2, y2, 0, 0); - - return self; -} - -construct(Circ,ShapeInterface) (Circ self, int x1, int y1, int r) -{ - self->comment = "Circle"; - interface_of(self)->count++; - _(reset, self, x1, y1, r, 0, 0, 0); - - return self; -} - -/* registration of implemented methods to three interfaces of the same type */ - -PointInterface pointInterface(void) -{ - Get_mem(this, PointInterface); - - this->draw = NULL; - this->move = movePoint; - this->desc = descPoint; - this->rename = NULL; - this->reset = setTri; - this->area = calcAreaTri; - this->count = 0; - - return this; -} - -ShapeInterface triInterface(void) -{ - Get_mem(this, ShapeInterface); - - this->draw = drawTri; - this->move = moveTri; - this->desc = descTri; - this->rename = NULL; - this->reset = setTri; - this->area = calcAreaTri; - this->count = 0; - - return this; -} - -ShapeInterface rectInterface(void) -{ - Get_mem(this, ShapeInterface); - - this->draw = drawRect; - this->move = moveRect; - this->desc = descRect; - this->rename = nameRect; - this->reset = setRect; - this->area = calcAreaRect; - this->count = 0; - - return this; -} - -ShapeInterface circInterface(void) -{ - Get_mem(this, ShapeInterface); - - this->draw = drawCirc; - this->move = moveCirc; - this->desc = descCirc; - this->rename = NULL; - this->reset = setCirc; - this->area = calcAreaCirc; - this->count = 0; - - return this; -} - -/* usage of objects inside C<<1 program */ - -program -{ - ShapeInterface triangles = triInterface(); - ShapeInterface rectangles = rectInterface(); - ShapeInterface circles = circInterface(); - Object_list all = NULL, one; - - one = get_mem(Object_list); - one->object = get_obj_as(Shape, Rect, rectangles, 0, 10, 1, 11); - append(one, all); - - one = get_mem(Object_list); - one->object = get_obj_as(Shape, Tri, triangles, 0, 0, 0, 4, 3, 0); - append(one, all); - - one = get_mem(Object_list); - one->object = get_obj_as(Shape, Rect, rectangles, 10, 0, 11, 1); - append(one, all); - - one = get_mem(Object_list); - one->object = get_obj_as(Shape, Circ, circles, 0, 10, 1); - append(one, all); - - printf("We have created %d triangles, %d rectangles and %d circles:\n", - triangles->count, rectangles->count, circles->count); - - for_each(one, all) - { - _(draw, one->object); - printf("Area of this %s is %f (square pixels).\n", _(desc, one->object), _(area, one->object)); - printf("We have created %d instances of this type of object.\n", interface_of(one->object)->count); - - if(interface_of(one->object) == rectangles) - { - _(reset, one->object, 0, 0, 1, 1, 0, 0); - _(rename, one->object, "Renamed rectangle"); - } - else - { - _(move, one->object, 10, 10); - } - } - - print("Rectangles were reset to new size and renamed, other objects were moved:"); - for_each(one, all) - { - _(draw, one->object); - } -} diff --git a/demos/objects/objects-wiki.c b/demos/objects/objects-wiki.c deleted file mode 100644 index 08403cb..0000000 --- a/demos/objects/objects-wiki.c +++ /dev/null @@ -1,74 +0,0 @@ -#include "cll1.h" - -/* This is C<<1 rewrite of object polymorphism from - http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming - - Of course there are easier ways to do the same thing... :-) - (G)2008 xChas */ - -def_interface(Animal,Actions) -{ - str method(talk) (Animal self); -}; - -def_obj(Animal) -{ - interface(Actions); - str name; -}; - -construct(Animal,Actions) (Animal self, str name) -{ - self->name = name; - return self; -} - -/* implementation of methods */ - -str catTalk(Animal self) -{ - return "Meow!"; -} - -str dogTalk(Animal self) -{ - return "Arf! Arf!"; -} - -/* registration of methods to object interface */ - -Actions catActions(void) -{ - Get_mem(this, Actions); - - this->talk = catTalk; - return this; -} - -Actions dogActions(void) -{ - Get_mem(this, Actions); - - this->talk = dogTalk; - return this; -} - -/* usage of objects inside C<<1 program */ - -program -{ - int i; - Animal animal[3]; - Actions cat = catActions(); - Actions dog = dogActions(); - - animal[0] = get_obj(Animal, cat, "Missy"); - animal[1] = get_obj(Animal, cat, "Mr. Bojangles"); - animal[2] = get_obj(Animal, dog, "Lassie"); - - for_range(i, 0, 2) - { - print(animal[i]->name, ":", _(talk, animal[i])); - } - -} diff --git a/demos/performance/cll1-echo.c b/demos/performance/cll1-echo.c deleted file mode 100644 index 347d7af..0000000 --- a/demos/performance/cll1-echo.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "cll1.h" - -program -{ - unsigned long i; - for_range(i,1,10000000) - echo("stuff\n"); -} diff --git a/demos/performance/cll1-print.c b/demos/performance/cll1-print.c deleted file mode 100644 index 611f166..0000000 --- a/demos/performance/cll1-print.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "cll1.h" - -program -{ - repeat(10000000) - print("stuff"); -} diff --git a/demos/performance/cll1-print2.c b/demos/performance/cll1-print2.c deleted file mode 100644 index 662d41c..0000000 --- a/demos/performance/cll1-print2.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "cll1.h" - -program -{ - repeat(10000000) - print("stuff1","stuff2"); -} diff --git a/demos/performance/cll1.h b/demos/performance/cll1.h deleted file mode 120000 index 58b5d6f..0000000 --- a/demos/performance/cll1.h +++ /dev/null @@ -1 +0,0 @@ -../../cll1.h \ No newline at end of file diff --git a/demos/performance/cout.cpp b/demos/performance/cout.cpp deleted file mode 100644 index cd47ab2..0000000 --- a/demos/performance/cout.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include - -#define RUNS 10000000UL -int main() -{ - unsigned long i; - for (i=0;i - -#define RUNS 10000000UL -int main() -{ - unsigned long i; - for (i=0;i diff --git a/demos/performance/echo2.php b/demos/performance/echo2.php deleted file mode 100755 index dd4c337..0000000 --- a/demos/performance/echo2.php +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/php5 -q - diff --git a/demos/performance/fputs.c b/demos/performance/fputs.c deleted file mode 100644 index 9c03bd1..0000000 --- a/demos/performance/fputs.c +++ /dev/null @@ -1,12 +0,0 @@ -#include - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - for (i=0;i - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - for (i=0;i -#include - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - char *s1="stuff\n"; - int l1=strlen(s1); - - for (i=0;i -#include - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - char *s1="stuff1"; - char *s2="stuff2"; - int l1=strlen(s1); - int l2=strlen(s2); - - for (i=0;i - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - for (i=0;i - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - for (i=0;i - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - for (i=0;i test-results 2>&1 -./test-performance2.sh all > test-results2 2>&1 diff --git a/demos/performance/test-performance.sh b/demos/performance/test-performance.sh deleted file mode 100755 index 45cc4e0..0000000 --- a/demos/performance/test-performance.sh +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/bash -echo `grep "model name" /proc/cpuinfo |cut -f 2 -d :` `grep "cpu MHz" /proc/cpuinfo |cut -f 2 -d :` Mhz ` grep "bogomips" /proc/cpuinfo |cut -f 2 -d :` bogomips - -if [ "$1" == "all" ] -then - echo "------------------------------------------------------------- Ruby" - cat print.rb - echo -n "Running..." - time ./print.rb > /dev/null - - echo "--------------------------------------------------- Python - range" - cat print.py - echo -n "Running..." - time ./print.py > /dev/null - - echo "-------------------------------------------------- Python - xrange" - cat xrange.py - echo -n "Running..." - time ./xrange.py > /dev/null - - echo "------------------------------------------------------------ PHP 5" - cat echo.php - echo -n "Running..." - time ./echo.php > /dev/null -fi - -echo "-------------------------------------------------- C - gcc - write" -cat write.c -echo -n "Compiling..." -time gcc -O2 write.c -o write -echo -n "Running..." -time ./write > /dev/null - -echo "------------------------------------------------------------- Perl" -cat print.pl -echo -n "Running..." -time ./print.pl > /dev/null - -echo "----------------------------------------------- C<<1 - gcc - print" -cat cll1-print.c -echo -n "Compiling..." -time gcc -O2 cll1-print.c -o cll1-print -echo -n "Running..." -time ./cll1-print > /dev/null - -echo "---------------------------------------------- C - g++ - std::cout" -cat cout.cpp -echo -n "Compiling..." -time g++ -O2 cout.cpp -o cout -echo -n "Running..." -time ./cout > /dev/null - -echo "----------------------------------------------- C<<1 - tcc - print" -cat cll1-print.c -echo -n "Compiling..." -time tcc cll1-print.c -o cll1-print -echo -n "Running..." -time ./cll1-print > /dev/null - -echo "------------------------------------------------- C - tcc - printf" -cat printf.c -echo -n "Compiling..." -time tcc printf.c -o printf -echo -n "Running..." -time ./printf > /dev/null - -echo "------------------------------------------------ C<<1 - tcc - echo" -cat cll1-echo.c -echo -n "Compiling..." -time tcc cll1-echo.c -o cll1-echo -echo -n "Running..." -time ./cll1-echo > /dev/null - -echo "--------------------------------------------------- C - tcc - puts" -cat puts.c -echo -n "Compiling..." -time tcc puts.c -o puts -echo -n "Running..." -time ./puts > /dev/null - -echo "------------------------------------------------- C - tcc - fwrite" -cat fwrite.c -echo -n "Compiling..." -time tcc fwrite.c -o fwrite -echo -n "Running..." -time ./fwrite > /dev/null - -echo "-------------------------------------------------- C - tcc - fputs" -cat fputs.c -echo -n "Compiling..." -time tcc fputs.c -o fputs -echo -n "Running..." -time ./fputs > /dev/null - -echo "------------------------------------------------ C<<1 - gcc - echo" -cat cll1-echo.c -echo -n "Compiling..." -time gcc -O2 cll1-echo.c -o cll1-echo -echo -n "Running..." -time ./cll1-echo > /dev/null - -echo "------------------------------------------------- C - gcc - printf" -cat printf.c -echo -n "Compiling..." -time gcc -O2 printf.c -o printf -echo -n "Running..." -time ./printf > /dev/null - -echo "--------------------------------------------------- C - gcc - puts" -cat puts.c -echo -n "Compiling..." -time gcc -O2 puts.c -o puts -echo -n "Running..." -time ./puts > /dev/null - -echo "------------------------------------------------- C - gcc - fwrite" -cat fwrite.c -echo -n "Compiling..." -time gcc -O2 fwrite.c -o fwrite -echo -n "Running..." -time ./fwrite > /dev/null - -echo "-------------------------------------------------- C - gcc - fputs" -cat fputs.c -echo -n "Compiling..." -time gcc -O2 fputs.c -o fputs -echo -n "Running..." -time ./fputs > /dev/null - diff --git a/demos/performance/test-performance2.sh b/demos/performance/test-performance2.sh deleted file mode 100755 index 73b0a7f..0000000 --- a/demos/performance/test-performance2.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/bash -echo `grep "model name" /proc/cpuinfo |cut -f 2 -d :` `grep "cpu MHz" /proc/cpuinfo |cut -f 2 -d :` Mhz ` grep "bogomips" /proc/cpuinfo |cut -f 2 -d :` bogomips - -if [ "$1" == "all" ] -then - echo "------------------------------------------------------------- Ruby" - cat print2.rb - echo -n "Running..." - time ./print2.rb > /dev/null - echo - - echo "--------------------------------------------------- Python - range" - cat print2.py - echo -n "Running..." - time ./print2.py > /dev/null - echo - - echo "-------------------------------------------------- Python - xrange" - cat xrange2.py - echo -n "Running..." - time ./xrange2.py > /dev/null - echo - - echo "------------------------------------------------------------ PHP 5" - cat echo2.php - echo -n "Running..." - time ./echo2.php > /dev/null - echo -fi - -echo "-------------------------------------------------- C - gcc - write" -cat write2.c -echo -n "Compiling..." -time gcc -O2 write2.c -o write2 -echo -n "Running..." -time ./write2 > /dev/null -echo - -echo "---------------------------------------------- C - g++ - std::cout" -cat cout2.cpp -echo -n "Compiling..." -time g++ -O2 cout2.cpp -o cout2 -echo -n "Running..." -time ./cout2 > /dev/null -echo - -echo "------------------------------------------------------------- Perl" -cat print2.pl -echo -n "Running..." -time ./print2.pl > /dev/null -echo - -echo "------------------------------------------------- C - tcc - printf" -cat printf2.c -echo -n "Compiling..." -time tcc printf2.c -o printf2 -echo -n "Running..." -time ./printf2 > /dev/null -echo - -echo "------------------------------------------------- C - tcc - fwrite" -cat fwrite2.c -echo -n "Compiling..." -time tcc fwrite2.c -o fwrite2 -echo -n "Running..." -time ./fwrite2 > /dev/null -echo - -echo "----------------------------------------------- C<<1 - tcc - print" -cat cll1-print2.c -echo -n "Compiling..." -time tcc cll1-print2.c -o cll1-print2 -echo -n "Running..." -time ./cll1-print2 > /dev/null -echo - -echo "-------------------------------------------------- C - tcc - fputs" -cat fputs2.c -echo -n "Compiling..." -time tcc fputs2.c -o fputs2 -echo -n "Running..." -time ./fputs2 > /dev/null -echo - -echo "------------------------------------------------- C - gcc - printf" -cat printf2.c -echo -n "Compiling..." -time gcc -O2 printf2.c -o printf2 -echo -n "Running..." -time ./printf2 > /dev/null -echo - -echo "------------------------------------------------- C - gcc - fwrite" -cat fwrite2.c -echo -n "Compiling..." -time gcc -O2 fwrite2.c -o fwrite2 -echo -n "Running..." -time ./fwrite2 > /dev/null -echo - -echo "----------------------------------------------- C<<1 - gcc - print" -cat cll1-print2.c -echo -n "Compiling..." -time gcc -O2 cll1-print2.c -o cll1-print2 -echo -n "Running..." -time ./cll1-print2 > /dev/null -echo - -echo "-------------------------------------------------- C - gcc - fputs" -cat fputs2.c -echo -n "Compiling..." -time gcc -O2 fputs2.c -o fputs2 -echo -n "Running..." -time ./fputs2 > /dev/null diff --git a/demos/performance/test-results b/demos/performance/test-results deleted file mode 100644 index ae344a7..0000000 --- a/demos/performance/test-results +++ /dev/null @@ -1,342 +0,0 @@ -AMD Athlon(tm) XP 1259.392 Mhz 2520.58 bogomips -------------------------------------------------------------- Ruby -#!/usr/bin/ruby - -10000000.times { print "stuff","\n" } - -Running... -real 0m31.160s -user 0m29.546s -sys 0m1.548s ---------------------------------------------------- Python - range -#!/usr/bin/python - -for i in range(1,10000000): - print "stuff" - -Running... -real 0m18.386s -user 0m17.757s -sys 0m0.308s --------------------------------------------------- Python - xrange -#!/usr/bin/python - -for i in xrange(1,10000000): - print "stuff" - -Running... -real 0m18.832s -user 0m18.805s -sys 0m0.024s ------------------------------------------------------------- PHP 5 -#!/usr/bin/php5 -q - -Running... -real 0m10.832s -user 0m7.696s -sys 0m2.544s --------------------------------------------------- C - gcc - write -#include - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - char *s1="stuff\n"; - int l1=strlen(s1); - - for (i=0;i - -#define RUNS 10000000UL -int main() -{ - unsigned long i; - for (i=0;i - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - for (i=0;i - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - for (i=0;i -#include - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - char *s1="stuff\n"; - int l1=strlen(s1); - - for (i=0;i - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - for (i=0;i - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - for (i=0;i - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - for (i=0;i -#include - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - char *s1="stuff\n"; - int l1=strlen(s1); - - for (i=0;i - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - for (i=0;i -Running... -real 0m18.649s -user 0m14.449s -sys 0m4.200s - --------------------------------------------------- C - gcc - write -#include - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - char *s1="stuff1"; - char *s2="stuff2"; - int l1=strlen(s1); - int l2=strlen(s2); - - for (i=0;i - -#define RUNS 10000000UL -int main() -{ - unsigned long i; - for (i=0;i - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - for (i=0;i -#include - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - char *s1="stuff1"; - char *s2="stuff2"; - int l1=strlen(s1); - int l2=strlen(s2); - - for (i=0;i - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - for (i=0;i - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - for (i=0;i -#include - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - char *s1="stuff1"; - char *s2="stuff2"; - int l1=strlen(s1); - int l2=strlen(s2); - - for (i=0;i - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - for (i=0;i - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - char *s1="stuff\n"; - int l1=strlen(s1); - - for (i=0;i - -#define RUNS 10000000UL -int main (void) -{ - unsigned long i; - char *s1="stuff1"; - char *s2="stuff2"; - int l1=strlen(s1); - int l2=strlen(s2); - - for (i=0;ii=1; - zaznam->s="¾lu»ouèký kùò"; - insert(zaznam,zaznamy,order_by_int,i); - zaznam=get_mem(Zaznam); - zaznam->i=3; - zaznam->s="Úpìl Ïábelské"; - insert(zaznam,zaznamy,order_by_int,i); - zaznam=get_mem(Zaznam); - zaznam->i=4; - zaznam->s="ódy"; - insert(zaznam,zaznamy,order_by_int,i); - zaznam=get_mem(Zaznam); - zaznam->i=2; - zaznam->s="Hlavono¾ec - H je pøed Ch"; - insert(zaznam,zaznamy,order_by_int,i); - zaznam=get_mem(Zaznam); - zaznam->i=5; - zaznam->s="hurá - malé h"; - insert(zaznam,zaznamy,order_by_int,i); - for_each(zaznam,zaznamy) printf("i=%d, s=%s\n",zaznam->i,zaznam->s); - - print("1x append(zaznam,zaznamy);"); - zaznam=get_mem(Zaznam); - zaznam->i=0; - zaznam->s="Chleba - písmeno Ch"; - append(zaznam,zaznamy); - for_each(zaznam,zaznamy) printf("i=%d, s=%s\n",zaznam->i,zaznam->s); - - print("sort(zaznam,zaznamy,order_by_int_desc,i);"); - sort(zaznam,zaznamy,order_by_int_desc,i); - for_each(zaznam,zaznamy) printf("i=%d, s=%s\n",zaznam->i,zaznam->s); - - print("sort(zaznam,zaznamy,order_by_str,s);"); - sort(zaznam,zaznamy,order_by_str,s); - for_each(zaznam,zaznamy) printf("i=%d, s=%s\n",zaznam->i,zaznam->s); - - print("sort(zaznam,zaznamy,order_by_ascii,s);"); - sort(zaznam,zaznamy,order_by_ascii,s); - for_each(zaznam,zaznamy) printf("i=%d, s=%s\n",zaznam->i,zaznam->s); - - print("remove(zaznam,zaznamy,zaznam->i==0);"); - remove(zaznam,zaznamy,zaznam->i==0); - for_each(zaznam,zaznamy) printf("i=%d, s=%s\n",zaznam->i,zaznam->s); - - print("drop(zaznam,zaznamy);"); - drop(zaznam,zaznamy); - for_each(zaznam,zaznamy) printf("i=%d, s=%s\n",zaznam->i,zaznam->s); -} diff --git a/demos/shell.c b/demos/shell.c deleted file mode 100644 index ee6accf..0000000 --- a/demos/shell.c +++ /dev/null @@ -1,26 +0,0 @@ -#include "cll1.h" -#define STRLEN 1024 - -program -{ - char *str; - int i=0; - string(str,STRLEN); - - shell("echo \"XXX\nYYY\nZZZ\""); - input(str,STRLEN) printf("---> %s",str); - puts("[EOF]"); - - paste("A\nB\nC"); - input(str,STRLEN) printf("---> %s",str); - puts("[EOF]"); - - shell("ls"); - input(str,STRLEN) printf("%d ---> %s",i++,str); - puts("[EOF]"); - - shell("ls"); - system("wc -l"); - puts("[EOF]"); - -} diff --git a/demos/split.c b/demos/split.c deleted file mode 100644 index b79e3ca..0000000 --- a/demos/split.c +++ /dev/null @@ -1,37 +0,0 @@ -#include "cll1.h" - -struct Passwd -{ - char *username, *home, *shell; - int uid, gid; - list(Passwd); -} *etcpasswd,*passwd; - -program -{ - char *ptr; - FILE *f; - int col; - - parse("/etc/passwd") - { - col=1; - suffix(ptr,_,'\n'); - split(ptr,_,':') switch(col++) - { - case 1: create(passwd,Passwd);passwd->username=ptr;break; - case 3: passwd->uid=atoi(ptr);break; - case 4: passwd->gid=atoi(ptr);break; - case 6: passwd->home=ptr;break; - case 7: passwd->shell=ptr;insert(passwd,etcpasswd,sort_by,username);break; - } - } - done; - - puts("--------- /etc/passwd sorted by username ---------------"); - every(passwd,etcpasswd) printf("#%03d: %s\n",passwd->uid,passwd->username); - - puts("--------- /etc/passwd sorted by uid --------------------"); - sort(passwd,etcpasswd,order_by,uid); - every(passwd,etcpasswd) printf("#%03d: %s\n",passwd->uid,passwd->username); -} diff --git a/demos/strings.c b/demos/strings.c deleted file mode 100644 index e2a479a..0000000 --- a/demos/strings.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "cll1.h" - -program -{ - char *ptr; - - asprintf(&ptr,"%ld",123456789); - printf("strlen(\"%s\")=%d\n",ptr,strlen(ptr)); - - ptr=catf("%ld",123456789); - printf("strlen(\"%s\")=%d\n",ptr,strlen(ptr)); - -} diff --git a/demos/stromecek.c b/demos/stromecek.c deleted file mode 100644 index 40153a4..0000000 --- a/demos/stromecek.c +++ /dev/null @@ -1,18 +0,0 @@ -#include "cll1.h" - -program -{ - const int kmen=28; - int jehlici=0,vetev=0,stromecek=2; - - while(jehlici<=kmen) - { - repeat(kmen-jehlici) echo(" "); - echo("/"); - repeat(jehlici<<1) if (jehlici>1,vetev=0,stromecek++; - } - repeat(kmen) echo(" "); - print("||"); -} diff --git a/demos/trees.c b/demos/trees.c deleted file mode 100644 index 87de034..0000000 --- a/demos/trees.c +++ /dev/null @@ -1,70 +0,0 @@ -#include "cll1.h" - -def_mem(Leaf) -{ - int seq; - array(Leaf); -}; - -program -{ - Leaf leaf,root=NULL; - int newkey; - int seq=0; - int odd=1; - - print("Input values:"); - for_ints(newkey, 8,1,-2,745,-32,-64,27,4,-300,0,300,40,-30,-40,400, 200 ) - { - printf("%d. [%d]\n",seq,newkey); - - leaf=get_mem(Leaf); - leaf->seq=seq++; - - //store(leaf,root,newkey) is declared as: - - //init - leaf->__next=NULL; - leaf->__seek=NULL; - leaf->__key=newkey; - - //store new node without indexing, first - insert(leaf,root,order_by_num,__key); - - //reindex B+ tree - for(leaf=root;leaf->__next;leaf=leaf->__next) - { - //auto seek - if(!leaf->__seek && leaf->__next) - leaf->__seek=leaf->__next->__next; - - if(leaf->__key<=newkey) - { - if(leaf->__seek && leaf->__seek->__key>newkey) leaf->__seek=leaf->__seek->__next; - } - else - { - if(odd && leaf->__seek) - { - leaf->__seek==leaf->__seek->__next; - } - else - { - leaf->__seek=leaf->__next->__seek; - leaf->__next->__seek=NULL; - } - odd=1-odd; - } - } - } - - print("Values were stored as:"); - for_each(leaf,root) - { - printf("%d. [%d]",leaf->seq,leaf->__key); - if (leaf->__seek) - printf("-> %d. [%d]\n",leaf->__seek->seq,leaf->__seek->__key); - else - print(""); - } -} diff --git a/tools/bake b/tools/bake deleted file mode 100755 index dfeefb6..0000000 --- a/tools/bake +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -CONF="/etc/bake.conf" -CLL1CC=`which gcc` -CFLAGS="-std=c99 -Wall" -DEBUG=n - -function debugecho -{ - if [ $DEBUG == y ] - then - echo $1 - fi -} - -if [ "$1" == "" ] || [ "$EXE" == "$1" ] -then - echo "Usage: bake source.c or bake target" - exit -else - while [ "$1" != "" ] - do - EXE=`basename $1 .c` - if [ $1 == $EXE ] - then - SRC=$EXE.c - else - SRC=$1 - fi - debugecho "Filename: $SRC" - - LIBNAMES=`grep "^#define" $SRC|grep USE_LIBRARY_|cut -f 2 -d " "` - if ! [ -z "$LIBNAMES" ] - then - debugecho "Libraries: $LIBNAMES" - LIBS="" - for F in $LIBNAMES - do - LIBS="$LIBS `grep $F $CONF|cut -f 2 -d \ `" - done - fi - - PRENAMES=`grep "^#define" $SRC|grep USE_PREPROCESSOR_|cut -f 2 -d " "` - if ! [ -z "$PRENAMES" ] - then - debugecho "Precompilers: $PRENAMES" - for F in $PRENAMES - do - CMD=`grep $F $CONF|cut -f 2 -d " "` - gecho "$CMD" - $CMD - done - fi - - CMD="$CLL1CC $SRC -o $EXE $CFLAGS $LIBS" - echo "$CMD" - $CMD - shift - done -fi diff --git a/tools/bake.conf b/tools/bake.conf deleted file mode 100644 index 0dd65aa..0000000 --- a/tools/bake.conf +++ /dev/null @@ -1,5 +0,0 @@ -#/usr/bin/bake is simple and powerful replacement for make -USE_LIBRARY_MYSQL -lmysqlclient -USE_LIBRARY_FASTCGI -lfcgi -USE_PREPROCESSOR_CAKE /usr/bin/cake -USE_POSTPROCESSOR_STRIP /usr/bin/strip diff --git a/tools/cake.c b/tools/cake.c deleted file mode 100644 index 3563b1f..0000000 --- a/tools/cake.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "cll1.h" - -program -{ - int state = 0; - string filename = NULL,line = NULL; - file f = NULL; - - - try - { - f = file_write("_cake.c"); - for_directory_filenames(filename,"./") - { - for_file_lines(line,filename) - { - for_chars(znak,line) - { - switch(znak) - { - case '<': state - case '>': - case '?': - case 'C': - case '%': - case '{': - case '}': - default: - } - } - } - } - } - - if_exception_switch - { - case ERROR_FILE: - - } -} -- 2.30.2