Mercurial > repo
changeset 3840:38a5b4d8a98e
<oerjan> rm -R share/delvs-master; mv delvs-master share
author | HackBot |
---|---|
date | Wed, 25 Sep 2013 13:47:14 +0000 |
parents | 02b377019805 |
children | 9383f0dad9dc |
files | delvs-master/.gitignore delvs-master/Makefile delvs-master/README.md delvs-master/bf.c delvs-master/bf.h delvs-master/delvs delvs-master/delvs.h delvs-master/delvs.rb delvs-master/main.c delvs-master/samples/hi-bool.bf delvs-master/samples/hi.bf delvs-master/samples/multiply.bf delvs-master/samples/readfile.bf delvs-master/samples/writefile.bf delvs-master/samples/writetonull.bf share/delvs-master/.gitignore share/delvs-master/Makefile share/delvs-master/README.md share/delvs-master/bf.c share/delvs-master/bf.h share/delvs-master/delvs share/delvs-master/delvs.h share/delvs-master/delvs.rb share/delvs-master/main.c share/delvs-master/samples/hi-bool.bf share/delvs-master/samples/hi.bf share/delvs-master/samples/multiply.bf share/delvs-master/samples/readfile.bf share/delvs-master/samples/writefile.bf share/delvs-master/samples/writetonull.bf |
diffstat | 30 files changed, 577 insertions(+), 577 deletions(-) [+] |
line wrap: on
line diff
--- a/delvs-master/.gitignore Wed Sep 25 13:32:58 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
--- a/delvs-master/Makefile Wed Sep 25 13:32:58 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
--- a/delvs-master/README.md Wed Sep 25 13:32:58 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"
--- a/delvs-master/bf.c Wed Sep 25 13:32:58 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <stdbool.h> -#include <stdlib.h> -#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; -}
--- a/delvs-master/bf.h Wed Sep 25 13:32:58 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -#include <stdio.h> -#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); - */
--- a/delvs-master/delvs.h Wed Sep 25 13:32:58 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -#include <stdio.h> -#include <unistd.h> -#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); - */
--- a/delvs-master/delvs.rb Wed Sep 25 13:32:58 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
--- a/delvs-master/main.c Wed Sep 25 13:32:58 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#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 <filename>\n", argv[0]); - } - return 0; -}
--- a/delvs-master/samples/hi-bool.bf Wed Sep 25 13:32:58 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 -""""'"'".>
--- a/delvs-master/samples/hi.bf Wed Sep 25 13:32:58 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -+++++ +++++ [ - > +++++ ++ - > +++++ +++++ - > +++ - >+ - <<<< - -] -> ++ . -> + . -+++++ ++ . . -+++ . -> ++ . -<< +++++ +++++ +++++ . -> . +++ . ------- . -------- . -> + . -> .
--- a/delvs-master/samples/multiply.bf Wed Sep 25 13:32:58 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -;>; -< [ - > [ - > + - > + - << - - ] - > [ - < + - > - - ] - << - -] ->>> :
--- a/delvs-master/samples/readfile.bf Wed Sep 25 13:32:58 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -,----- ----- [ - +++++ +++++ - >, - ----- ----- -] -< [<] # -`+[-.`+]
--- a/delvs-master/samples/writefile.bf Wed Sep 25 13:32:58 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -,----- ----- [ - +++++ +++++ - >, - ----- ----- -] -< [<] + # -[,!]
--- a/delvs-master/samples/writetonull.bf Wed Sep 25 13:32:58 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 -[<] -+ # -> [!>]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/delvs-master/.gitignore Wed Sep 25 13:47:14 2013 +0000 @@ -0,0 +1,18 @@ +# Compiled Object files +*.slo +*.lo +*.o +*.out + +# Compiled Dynamic libraries +*.so +*.dylib + +# Compiled Static libraries +*.lai +*.la +*.a + +# Compiled executable binary +delvs +bfi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/delvs-master/Makefile Wed Sep 25 13:47:14 2013 +0000 @@ -0,0 +1,17 @@ +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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/delvs-master/README.md Wed Sep 25 13:47:14 2013 +0000 @@ -0,0 +1,100 @@ +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"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/delvs-master/bf.c Wed Sep 25 13:47:14 2013 +0000 @@ -0,0 +1,53 @@ +#include <stdio.h> +#include <string.h> +#include <stdbool.h> +#include <stdlib.h> +#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; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/delvs-master/bf.h Wed Sep 25 13:47:14 2013 +0000 @@ -0,0 +1,67 @@ +#include <stdio.h> +#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); + */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/delvs-master/delvs.h Wed Sep 25 13:47:14 2013 +0000 @@ -0,0 +1,111 @@ +#include <stdio.h> +#include <unistd.h> +#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); + */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/delvs-master/delvs.rb Wed Sep 25 13:47:14 2013 +0000 @@ -0,0 +1,71 @@ +#!/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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/delvs-master/main.c Wed Sep 25 13:47:14 2013 +0000 @@ -0,0 +1,45 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#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 <filename>\n", argv[0]); + } + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/delvs-master/samples/hi-bool.bf Wed Sep 25 13:47:14 2013 +0000 @@ -0,0 +1,26 @@ +01001000 H +"'""'""".> +01100101 e +"''""'"'.> +01101100 l +"''"''"".> +01101100 l +"''"''"".> +01101111 o +"''"''''.> +00100000 +""'""""".> +01010111 W +"'"'"'''.> +01101111 o +"''"''''.> +01110010 r +"'''""'".> +01101100 l +"''"''"".> +01100100 d +"''""'"".> +00100001 +""'""""'.> +00001010 +""""'"'".>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/delvs-master/samples/hi.bf Wed Sep 25 13:47:14 2013 +0000 @@ -0,0 +1,17 @@ ++++++ +++++ [ + > +++++ ++ + > +++++ +++++ + > +++ + >+ + <<<< - +] +> ++ . +> + . ++++++ ++ . . ++++ . +> ++ . +<< +++++ +++++ +++++ . +> . +++ . +------ . -------- . +> + . +> .
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/delvs-master/samples/multiply.bf Wed Sep 25 13:47:14 2013 +0000 @@ -0,0 +1,14 @@ +;>; +< [ + > [ + > + + > + + << - + ] + > [ + < + + > - + ] + << - +] +>>> :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/delvs-master/samples/readfile.bf Wed Sep 25 13:47:14 2013 +0000 @@ -0,0 +1,7 @@ +,----- ----- [ + +++++ +++++ + >, + ----- ----- +] +< [<] # +`+[-.`+]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/delvs-master/samples/writefile.bf Wed Sep 25 13:47:14 2013 +0000 @@ -0,0 +1,7 @@ +,----- ----- [ + +++++ +++++ + >, + ----- ----- +] +< [<] + # +[,!]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/delvs-master/samples/writetonull.bf Wed Sep 25 13:47:14 2013 +0000 @@ -0,0 +1,24 @@ ++++++ +++++ [ + > +++++ / + > +++++ +++++ d + > +++++ +++++ e + > +++++ +++++ ++ v + > +++++ / + > +++++ +++++ + n + > +++++ +++++ ++ u + > +++++ +++++ + l + > +++++ +++++ + l + [<] > - +] +> --- / +> d +> + e +> -- v +> --- / +> n +> --- u +> -- l +> -- l +[<] ++ # +> [!>]