diff interps/boof/boof.h @ 996:859f9b4339e6

<Gregor> tar xf egobot.tar.xz
author HackBot
date Sun, 09 Dec 2012 19:30:08 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/interps/boof/boof.h	Sun Dec 09 19:30:08 2012 +0000
@@ -0,0 +1,55 @@
+#ifndef boof_h_
+#define boof_h_
+
+/* A boolpit is an infinite array of bools (growable at both ends) */
+/* boof.h - by Sam Hughes - boof@samuelhughes.com */
+
+#include <string>
+#include <iostream>
+#include <vector>
+
+class boolpit {
+
+	unsigned char * beg_;
+	unsigned char * mid_;
+	unsigned char * end_;
+
+ public:
+
+	boolpit();
+	boolpit(const boolpit & copyee);
+	~boolpit();
+
+	boolpit & operator=(const boolpit & assignee);
+
+	void set(size_t offset, int i);
+	int get(size_t offset);
+	void flip(size_t offset);
+
+ private:
+	void copy(const boolpit & copyee);
+	void grow_and_accommodate(unsigned char * & p);
+
+
+};
+
+class boofer {
+	struct size_triad {
+		size_t lpos, rjump, bjump;
+		size_triad(size_t a, size_t b, size_t c)
+			: lpos(a), rjump(b), bjump(c) {}
+	};
+
+	std::string prog_;
+	std::vector<size_triad> brace_pos_;
+
+ public:
+	boofer(std::istream & istr);
+	void execute(std::istream & in, std::ostream & out) const;
+
+
+
+};
+
+
+#endif