Subset of C language with tree interpreter and bytecode compiler + VM.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

55 lines
1.3 KiB

#!./main
#include <stdio.h>
#include <stdint.h>
int x = 21;
int baz(int xx, ...) { return 42; }
int foo(void) { return x + x; }
char *bar(void) { return "bye bye"; }
int main(int argc, char **argv)
{
printf("hello, world %d %s\n", foo(), bar());
printf("baz is %d %d %d\n", baz(1), baz(1, 2), baz(1, "two", 3));
int x = 42;
int *p = &x;
printf("x is %d p is %p\n", *p, p);
*p = 666;
printf("x is %d %d\n", x, *p);
x = 123;
printf("x is %d %d\n", x, *p);
for (x = 0; x < 10; ++x) {
if (x == 5) printf("%%");
printf("%d ", x);
}
printf("\n");
while (x > 0) printf("%d ", --x);
printf("\n");
printf("%d\n", sizeof(char *));
int i, array[5] = { 2, 3, 5, 7, 11 };
printf("array size %d\n", sizeof(array));
for (i = 0; i < 5; ++i) printf("%d\n", array[i]);
for (i = 0; i < 5; ++i) array[i] = i*i;
for (i = 0; i < 5; ++i) printf("%d\n", array[i]);
for (i = 0; i < 5; ++i) array[i] = array[i] * array[i];
for (i = 0; i < 5; ++i) printf("%d\n", array[i]);
printf("%p\n", array);
printf("%p\n", array + 10);
p = array;
printf("%p\n", p);
printf("%p\n", array+5);
while (p < array+5) printf("%d\n", *p++);
return 0;
}
// Local Variables:
// mode: c
// End: