demo "lists" prepsano na for each(...) a prelozi se
[svn/Cll1h/.git] / cll1.txt
CommitLineData
30628092 1
2C<<1: The Programming Language
3==============================
4
5Feedback: xchaos@arachne.cz
6Homepage: http://gpl.arachne.cz
7
8Copyright (G) 2004 Michael Polak, x@n.cz
9C<<1 is available under terms of GNU Lesser Public License (LGPL)
10This file is available under terms of GNU Free Documentation License
11
121. Introduction
13---------------
14
15There are various extensions and definitions of classical C language,
16for example object oriented "C++" and "Objective C", minimalistic C--,
17proprietary C# used by .Net project, etc. Many other modern languages
18
19C<<1 is designed to work as "stylesheet" for very classical ANSI C, and
20it was specificaly tested to work fine with GNU C Compiler gcc. There is
21no special C<<1 compiler or interpreter; instead, you are expected to
22include special header file called cll1.h the same way you would include
23let's say string or I/O library implemented in standard C library. Except
24that you don't need to link your executable with any special library,
25neither staticaly nor dynamicaly, and you don't have to configure your gcc
26or make to do so.
27
28#include <cll1.h>
29
30Or #include "cll1.h", if cll1.h is not installed in your /usr/include
31directory. That'it. No linking, no initialization, allocation, or so.
32
33C<<1 can be used for dummy, structured or object oriented programing,
34whatever method you prefere. C<<1 focuses mainly on adding new complex
35semantic structures into C, rather than inventing brand new syntax or class
36hieararchy, or providing set of pre-defined library functions. To allow
37that, most of C<<1 functions are implemented as macros for C preprocessor.
38
392. Getting started
40------------------
41
42#include <cll1.h>
43
44program
45{
46 puts("Hello World!");
47}
48
49Of course, int main(int argc,void **argv) can be still used. In fact,
50macro "program" doesn't do much more than that ! Following program prints
51all arguments:
52
53program
54{
55 char *ptr;
56
57 arguments
58 {
59 thisargument(ptr);
60 puts(ptr);
61 }
62 else
63 puts("Bleeeeh, no arguments supplied... :-(");
64}
65
66Well, don't be surprised with "else" after "arguments". This is not the
67last time in C<<1, when you will see C keywords somewhere you don't expect
68them. Of course, you would like to use it this way, I guess:
69
70program
71{
72 char *ptr;
73
74 arguments
75 {
76 argument("-?") printf("This is just help!\n");
77 else argument("-f") { nextargument(ptr) printf("Forced argument: %s\n",ptr); }
78 else { thisargument(ptr); printf("Simple argument: %s \n",ptr); }
79 }
80 else
81 puts("Bleeeeh, no arguments supplied... :-(");
82}
83
842. Where is my main() funciton ?!
85---------------------------------
86
87If you want to use int main(int argc,void **argv) { } instead of
88program { }, it's ok. Being fan of Basic and not Pascal, I don't
89like the program keyword at all. In fact, by avoiding "program" construct
90and using standard main() declaration, you would be still able to access
91most of C<<1 functionality, but for example not the arguments() structure
92mentioned above.
93
943. Ok, let's go on
95------------------
96
97This is some code to send e-mail using unix sendmail:
98(ok, nothing special, same as "echo .... | sendmail ....")
99
100program
101{
102 paste("From: me@here\nSubject: Here we go...\n\nblah blah blah")
103 system("/usr/sbin/sendmail someone@somewhere");
104}
105
106This program prints exactly 6th column of /etc/passwd file
107(ok, nothing special, same as "cut -f 6 -d : /etc/passwd")
108
109program
110{
111 char *ptr;
112 parse("/etc/passwd")
113 {
114 column(ptr,_,':',6);
115 if(ptr)puts(ptr);
116 }
117 done;
118}
119
120But next program prints 1st and 6th column of /etc/passwd.
121(What is equivalent in bash ?)
122
123program
124{
125 char *ptr;
126 int i;
127 parse("/etc/passwd")
128 {
129 columns(ptr,_,':',i) switch(i)
130 {
131 case 1: printf("%s...",ptr); break;
132 case 6: puts(ptr);
133 }
134 }
135 done;
136}
137
138
1394. Groups of C<<1 macros
140------------------------
141
142! - macro is available only when using "program" instead of "main()"
143
144I. Unconditional iterations - without else
145
146every
147iterate
148repeat !
149
150II. Conditional iterations - else can happen once
151
152find
153arguments !
154argument
155nextargument
156
157III. Conditional iterations - else can happen many times
158
159search
160valid_split
161valid_columns
162
163IV. Weird iterations (with something special)
164
165parse - [fail] - done
166
167V. Standalone sequences - they look like function calls, but they are not.
168
169insert
170append
171push
172remove
173sort
174shell
175paste
176column
177valid_column
178...
179
180VI. Well behaved seqences - can be used anywhere where functions can.
181
182create
183string
184goto_*
185prefix
186suffix
187...
188
1895. Forbidden namespace
190----------------------
191
192Variables starting with _ (underscored) followed by one or more capital
193characters (A-Z) are reserved as C<<1 private compile-time namespace.
194
1956. Compile time errors
196----------------------
197
198- parse error at end of input
199
200You probably forgot to close some macro which must be obligatory
201terminated by another macro - as "parse error" message suggests,
202it is likely to be error in macro "parse() { } [ fail ] { } done; "
203
204:-)
205
2067. We apologize for inconvenience
207---------------------------------
208
209This documentation file is unfortunately incomplete.
210HTML online documentation is comming soon ... sooner ... or later...
This page took 0.230424 seconds and 4 git commands to generate.