# HG changeset patch # User HackBot # Date 1371363614 0 # Node ID f2150989e59f4b60442ad4f5b8caecc226607800 # Parent 0e357bf3dcb9873fb295c5188646be274a69da7f rm -rf delvs-master diff -r 0e357bf3dcb9 -r f2150989e59f delvs-master/.gitignore --- a/delvs-master/.gitignore Sun Jun 16 06:18:20 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -# Compiled Object files -*.slo -*.lo -*.o -*.out - -# Compiled Dynamic libraries -*.so -*.dylib - -# Compiled Static libraries -*.lai -*.la -*.a - -# Compiled executable binary -delvs -bfi diff -r 0e357bf3dcb9 -r f2150989e59f delvs-master/Makefile --- a/delvs-master/Makefile Sun Jun 16 06:18:20 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -CC=gcc -CFLAGS=-Wall -std=c11 -Werror -LDFLAGS= -SOURCES=main.c -OBJECTS=$(SOURCES:.c=.o) - -all: objects - mv main.o delvs - -objects: - $(CC) $(CFLAGS) $(SOURCES) -o $(OBJECTS) - -clean: - rm -f delvs bfi *.o - -vanilla: - $(CC) $(CFLAGS) bf.c -o bfi diff -r 0e357bf3dcb9 -r f2150989e59f delvs-master/README.md --- a/delvs-master/README.md Sun Jun 16 06:18:20 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -Delvs -===== - -Delvs(Pronounced Del-vis) is my own personal variation of brainfuck, the interpreter is written in C. -File reading was inspired by brainfuck++, and the bit fiddling was inspired by boolfuck(DuckDuckGo them if you have to, I'm not putting links there right now) - -Additions ---------- -- `:` casts the current value to a string and prints it. Code: `printf("%hhd", *p);` -- `;` grabs value from user input and casts to cell value. Code: `scanf("%hhd", p);` -- `#` reads following cells as null-terminating string for filename, then if current cell is != 1, open file for reading, or if 1, open file writing. Code: `f = fopen(p + 1, p == 1 ? "w" : "r");` -- `` ` `` read next char from file, apply to current cell. (`EOF` becomes `0`) Code: `*p = fgetc(f);` -- `!` write char from current cell to file. Code: `fputc(*p, f);` -- `"` increment current bit position by 1. (psuedo)Code: `b++;` -- `'` flip bit at current bit position, then incrment current bit position by 1. Code: `*p ^= (1 << b)` -- `\ ...` ignore EVERYTHING until newline is reached. `while(*c) if(*c++ == '\') return;` -- `@` prints value of current cell and surrounding 4 cells. Code: -- `$` sleeps the current cell's value in seconds - -### To do -- implement a working socket system -- implement an stdout flushing system -- implement runtime args -- implement namespaces(seperate arrays of 30000 chars) -- (maybe) implement better way to divide -- implement full integers - -Examples --------- -Setting entire cell values with just the bit intructions is as easy as converting 0's to `"`s and 1's to `'`s. - - 01001000 = 72 - "'""'""" . > - 01101001 = 105 - "''"'""' . - -Block comments are very straight forward to use, just plant a `\[` when you start "commenting" and a `]` when you're done. - - +++++ +++++ [ - > +++++ ++ - > +++++ +++++ - \ This is a well placed comment. See, all these code intrustions aren't messing with the program unlike vanilla Brainfuck - > +++ - > + - <<<< - - ] - > ++ . - > + . - +++++ ++ . . - \ Another intruding comment. - +++ . - > ++ . - << +++++ +++++ +++++ . - > . +++ . - ------ . -------- . - > + . - > . - -How about reading files? Just generate a string as the filename an the use a `#` at the beginning of it. Like so: - - 01101101 m - "''"''"' - 01111001 y - "''''""' - 01110100 t - "'''"'"" - 01100101 e - "''""'"' - 01111000 x - "''''""" - 01110100 t - "'''"'"" - 01100110 f - "''""''" - 01101001 i - "''"'""' - 01101100 l - "''"''"" - 01100101 e - "''""'"' - 00101110\. - ""'"'''" - 01110100 t - "'''"'"" - 01111000 x - "''''""" - 01110100 t - "'''"'"" - - [<] # - \ standard concatenation loop with file reading(and EOF check) - `+[-.`+] - -Want to give the actual value of the cell when printing? Just add a dot above your intruction! - - 01100100 \ 'd' or 100 - "''""'"" - - . \ prints "d" - : \ prints "100" diff -r 0e357bf3dcb9 -r f2150989e59f delvs-master/bf.c --- a/delvs-master/bf.c Sun Jun 16 06:18:20 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -#include -#include -#include -#include -#include "bf.h" - -bool fileExists(const char *filename) { - FILE *file; - if ((file = fopen(filename, "r")) == NULL) { - return false; - } else { - fclose(file); - return true; - } -} - -int main(int argc, char *argv[]) { - if(argc > 1) { - if(fileExists(argv[1])) { - FILE *fp; - long size; - - fp = fopen(argv[1], "r"); - - fseek(fp, 0, SEEK_END); - size = ftell(fp); - rewind(fp); - - char *temp = (char*) malloc (100); - - char *file = (char*) malloc (size); - - file[0] = '\0'; - - while (fgets(temp, 100, fp) != NULL) strcat(file, temp); - - free(temp); - fclose(fp); - - struct Data g; - - g.code = file; - g.pointer = &g.vars[15000]; - - lexer(&g); - } - else { - printf("File not found!\n"); - } - } - - return 0; -} diff -r 0e357bf3dcb9 -r f2150989e59f delvs-master/bf.h --- a/delvs-master/bf.h Sun Jun 16 06:18:20 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -#include -#define c g->code -#define p g->pointer -#define f g->file - -struct Data { - const char *code; - char vars[30000]; - char *pointer; -}; - -void dummyLexer(struct Data *g) { while(*c) if(*c++ == ']') return; } - -void lexer(struct Data *g) { - const char *cc = c; - while(*c) { - switch (*c++) { - case '>': - ++p; - break; - - case '<': - --p; - break; - - case '+': - ++*p; - break; - - case '-': - --*p; - break; - - case '.': - putchar(*p); - break; - - case ',': - *p = getchar(); - break; - - case '[': - cc = c; - if(!*p) dummyLexer(g); - while(*p) { - c = cc; // restore char position to start of loop - lexer(g); - } - break; - - case ']': - return; - - default: - // everything else is comments - break; - } - } - return; -} -/* - * Usage: - * struct Data g; - * g.code = file; - * g.pointer = &g.data[15000]; - * lexer(&g); - */ diff -r 0e357bf3dcb9 -r f2150989e59f delvs-master/delvs.h --- a/delvs-master/delvs.h Sun Jun 16 06:18:20 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -#include -#include -#define c g->code -#define p g->pointer -#define f g->file -#define b g->bit - -struct Data { - const char *code; - char vars[30000]; - char *pointer; - char bit; - FILE *file; -}; - -void lexer(struct Data *g) { - const char *cc = c; - while(*c) - switch (*c++) { - case '>': - ++p; - break; - - case '<': - --p; - break; - - case '+': - ++*p; - break; - - case '-': - --*p; - break; - - case '.': - putchar(*p); - break; - - case ',': - *p = getchar(); - break; - - case '[': - cc = c; - if(!*p) while(*c++ != ']'); - while(*p) { - c = cc; // restore char position to start of loop - lexer(g); - } - break; - - case ']': - return; - - case ':': - printf("%hhd", *p); - break; - - case ';': - scanf("%hhd", p); - break; - - case '#': - // open in read mode unless the cell is 1 - if(f) fclose(f); - f = fopen(p + 1, *p == 1 ? "w" : "r"); - break; - - case '`': - *p = fgetc(f); - break; - - case '!': - fputc(*p, f); - break; - - case '\'': - *p ^= (1 << b); - b <= 0 ? b = 7 : b--; - break; - - case '"': - b <= 0 ? b = 7 : b--; - break; - - case '\\': - while(*c++ != '\n'); - break; - - case '@': - printf("%hhd : %hhd : %hhd : %hhd : %hhd", *(p - 2), *(p - 1), *p, *(p + 1), *(p + 2)); - break; - - case '$': - sleep(*p); - break; - - default: - // everything else is comments - break; - } -} -/* - * Usage: - * struct Data g; - * g.code = "code here"; - * g.bit = 7; - * g.pointer = &g.data[15000]; - * lexer(&g); - */ diff -r 0e357bf3dcb9 -r f2150989e59f delvs-master/delvs.rb --- a/delvs-master/delvs.rb Sun Jun 16 06:18:20 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -#!/usr/bin/env ruby -# NOTE: this proram was just made for the lulz, PLEASE DO NOT USE THIS -# Please use the actually semi-well written delvs interpreter writtin in C, because this isn't even close to the actual delvs interpreter -require 'io/console' - -class RuntimeData - attr_accessor :c - attr_accessor :v - attr_accessor :i - attr_accessor :f - attr_accessor :p - - def initialize - @c = "" - @i = 0 - @v = Array.new 30000, 0 - @p = 15000 - @f = "" - end -end - -def dummy_lexer d - while d.i <= d.c.length do - return d.i if d.c[d.i] == ']' - d.i += 1 - end -end - -def lexer d - while d.i <= d.c.length do - case d.c[d.i] - when '>' then - d.p += 1 - - when '<' then - d.p -= 1 - - when '+' then - d.v[d.p] += 1 - - when '-' then - d.v[d.p] -= 1 - - when '.' then - print d.v[d.p].chr - - when ',' then - d.v[d.p] = IO.console.getch.ord - - when '[' then - r = d.i + 1 - d.i = dlexer d if !d.v[d.p] - while d.v[d.p] != 0 do - d.i = r - d = lexer d - end - - when ']' then - return d - - else - # Everything else is comments - end - d.i += 1 - end -end - -# example usage: -# data = RuntimeData.new -# data.c = "+++++ +++++ [ > +++++ +++++ > + << - ] > ++++ . + . > ." -# lexer data diff -r 0e357bf3dcb9 -r f2150989e59f delvs-master/main.c --- a/delvs-master/main.c Sun Jun 16 06:18:20 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -#include -#include -#include -#include "delvs.h" - -int main(int argc, char *argv[]) { - if(argc > 1) { - FILE *fp; - long size; - - fp = fopen(argv[1], "r"); - - if(fp == NULL) { - printf("File: \"%s\" not found\n", argv[1]); - return 1; - } - - fseek(fp, 0, SEEK_END); - size = ftell(fp); - rewind(fp); - - char *temp = (char*) malloc (100); - - char *file = (char*) malloc (size); - - file[0] = '\0'; - - while (fgets(temp, 100, fp) != NULL) strcat(file, temp); - - free(temp); - fclose(fp); - - struct Data g; - - g.code = file; - g.bit = 7; - g.pointer = &g.vars[15000]; - - lexer(&g); - } - else { - printf("Usage: %s \n", argv[0]); - } - return 0; -} diff -r 0e357bf3dcb9 -r f2150989e59f delvs-master/samples/hi-bool.bf --- a/delvs-master/samples/hi-bool.bf Sun Jun 16 06:18:20 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -01001000 H -"'""'""".> -01100101 e -"''""'"'.> -01101100 l -"''"''"".> -01101100 l -"''"''"".> -01101111 o -"''"''''.> -00100000 -""'""""".> -01010111 W -"'"'"'''.> -01101111 o -"''"''''.> -01110010 r -"'''""'".> -01101100 l -"''"''"".> -01100100 d -"''""'"".> -00100001 -""'""""'.> -00001010 -""""'"'".> diff -r 0e357bf3dcb9 -r f2150989e59f delvs-master/samples/hi.bf --- a/delvs-master/samples/hi.bf Sun Jun 16 06:18:20 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -+++++ +++++ [ - > +++++ ++ - > +++++ +++++ - > +++ - >+ - <<<< - -] -> ++ . -> + . -+++++ ++ . . -+++ . -> ++ . -<< +++++ +++++ +++++ . -> . +++ . ------- . -------- . -> + . -> . diff -r 0e357bf3dcb9 -r f2150989e59f delvs-master/samples/multiply.bf --- a/delvs-master/samples/multiply.bf Sun Jun 16 06:18:20 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -;>; -< [ - > [ - > + - > + - << - - ] - > [ - < + - > - - ] - << - -] ->>> : diff -r 0e357bf3dcb9 -r f2150989e59f delvs-master/samples/readfile.bf --- a/delvs-master/samples/readfile.bf Sun Jun 16 06:18:20 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -,----- ----- [ - +++++ +++++ - >, - ----- ----- -] -< [<] # -`+[-.`+] diff -r 0e357bf3dcb9 -r f2150989e59f delvs-master/samples/writefile.bf --- a/delvs-master/samples/writefile.bf Sun Jun 16 06:18:20 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -,----- ----- [ - +++++ +++++ - >, - ----- ----- -] -< [<] + # -[,!] diff -r 0e357bf3dcb9 -r f2150989e59f delvs-master/samples/writetonull.bf --- a/delvs-master/samples/writetonull.bf Sun Jun 16 06:18:20 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -+++++ +++++ [ - > +++++ / - > +++++ +++++ d - > +++++ +++++ e - > +++++ +++++ ++ v - > +++++ / - > +++++ +++++ + n - > +++++ +++++ ++ u - > +++++ +++++ + l - > +++++ +++++ + l - [<] > - -] -> --- / -> d -> + e -> -- v -> --- / -> n -> --- u -> -- l -> -- l -[<] -+ # -> [!>]