# HG changeset patch # User meillo@marmaro.de # Date 1202385114 -3600 # Node ID 2f71d692d4f915545099059e5062252ddb448f7f initial commit diff -r 000000000000 -r 2f71d692d4f9 .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Thu Feb 07 12:51:54 2008 +0100 @@ -0,0 +1,6 @@ +syntax: glob +*~ +*.swp + +*.o +baum diff -r 000000000000 -r 2f71d692d4f9 Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Thu Feb 07 12:51:54 2008 +0100 @@ -0,0 +1,51 @@ +# common makefile + +# program +PROGRAM = baum +SRC = baum.c +OBJ = ${SRC:.c=.o} +DEP = + +# compile env +CC = gcc +LD = ${CC} +DEBUG = -g +CFLAGS = -Wall -c ${DEBUG} +LFLAGS = -Wall ${DEBUG} + +#### + +all: options ${PROGRAM} + +options: + @echo build options: + @echo "CC = ${CC}" + @echo "LD = ${LD}" + @echo "CFLAGS = ${CFLAGS}" + @echo "LFLAGS = ${LFLAGS}" + @echo + +.cpp.o: + $(CC) $(CFLAGS) $< + +${OBJ}: ${DEP} + +${PROGRAM}: ${OBJ} + $(LD) $(LFLAGS) ${OBJ} -o $@ + +debug: all + gdb ${PROGRAM} + +strip: ${PROGRAM} + @echo stripping ${PROGRAM} + @strip ${PROGRAM} + +tar: clean + @echo creating archive + @tar -czvf ${PROGRAM}.tar.gz * + +clean: + @echo cleaning + @rm -f ${PROGRAM} ${OBJ} + +.PHONY: all options debug strip tar clean diff -r 000000000000 -r 2f71d692d4f9 baum.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/baum.c Thu Feb 07 12:51:54 2008 +0100 @@ -0,0 +1,70 @@ +/* + * baum - an esoteric programming language + * + * (c) markus schnalke + * and julian forster + * + */ + + +#include +#include + + +struct Node { + char* name; + char value; + struct Node* down; + struct Node* right; +}; + +struct Node* root; + + +struct Node* newNode(char* name) { + struct Node* node; + node = (struct Node*) malloc(sizeof(struct Node)); + node->name = name; + node->value = 0; + node->right = 0; + node->down = 0; + return node; +} + +void init() { + root = newNode("print"); + root->down = newNode("sum"); +} + +void cleanup(struct Node* node) { + if (node->down != NULL) { + cleanup(node->down); + } + if (node->right != NULL) { + cleanup(node->right); + } + free(node); node=0; +} + +void printNode(struct Node* node) { + printf("Node: %20s (%c)\n", node->name, node->value); +} + +void printTree(struct Node* root) { + printNode(root); + if (root->down != NULL) { + printTree(root->down); + } + if (root->right != NULL) { + printTree(root->right); + } +} + + +int main(int argc, char* argv[]) { + init(); + printTree(root); + cleanup(root); + + return(0); +}