Awesome
FIRST INSTALL
-
download and install MyDef (https://github.org/hzhou/MyDef.git)
-
define environment variable MYDEFSRC to your MyDef directory (e.g. $HOME/projects/MyDef)
-
mydef_make
-
make
-
make install
UPDATE
-
git pull origin master
-
make
-
make install
Examples
- Hello World
page: test, basic_frame
module: c
$print Hello World!
printf("%s? Just use straight C syntax.\n", "In doubt");
$ mydef_run test.def
PAGE: test
--> [./test.c]
gcc -std=c99 -O2 -o./test ./test.c && ./test
Hello World!
In doubt? Just use straight C syntax.
Explain: I assume you understand how MyDef generally works. basic_frame
is a subcode defined in std_c.def
, automatically included for module c. It included a definition of main
function and puts your main
code inside. For other c
code, simply drop basic_frame
or use a custom frame code of yours.
Remember, you are writing C code. So read test.c
for what you have wrote.
- For-loops
page: test, basic_frame
module: c
$call test_for, 10
$call test_for, i=0:9
$call test_for, i=0:9:2
$call test_for, i=9:0:-1
$local i
$call test_for, i=9;i>=0;i--
subcode: test_for(p)
$print "for $(p): -"
$for $(p)
$print $i -
$print
/* expect output:
for 10: 0 1 2 3 4 5 6 7 8 9
for i=0:9: 0 1 2 3 4 5 6 7 8
for i=0:9:2: 0 2 4 6 8
for i=9:0:-1: 9 8 7 6 5 4 3 2 1 0
# Note: convention can be tricky, consider explicit when convention is weak
for i=9;i>=0;i--: 9 8 7 6 5 4 3 2 1 0
*/
More examples may be found in the tests
folder. There are too many weird tricks possible with MyDef
. Wisdom and discipline highly recommended.