changeset 0:2f71d692d4f9

initial commit
author meillo@marmaro.de
date Thu, 07 Feb 2008 12:51:54 +0100 (2008-02-07)
parents
children 3da0ff17c8e7
files .hgignore Makefile baum.c
diffstat 3 files changed, 127 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /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
--- /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
--- /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 <meillo@marmaro.de>
+ * and julian forster
+ *
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+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);
+}