From 94ea551501a130b45a795c372d49a8aede276950 Mon Sep 17 00:00:00 2001 From: YanaRG Date: Tue, 27 Nov 2018 12:11:46 +0200 Subject: HW3.2 Brainf interpreter (#43) * Create README.md * Initial commit * Initial commit * Create README.md * Rename homework/81281/c2html.pl to homework/81281/c2html/c2html.pl * Rename homework/81281/test.c to homework/81281/c2html/test.c * Update README.md * Update README.md * Update c2html.pl * Update c2html.pl * Update c2html.pl * Update README.md * Update c2html.pl * Update test.c * Create executeProgram.sh * Update README.md * Update c2html.pl * Initial commit of updated code + prettify C * Rename secret.c to messyCode.c * Update and rename test.c to initialTest.c * Update README.md * Update README.md * Update README.md * Update README.md * Rename executeProgram.sh to c2htmlrun.sh * Update README.md * Update prettify.pl * Update prettify.pl * Update messyCode.c * Fixed some bugs. * Update README.md * Update c2html.pl * Added collapse and fixed matrix representation. * Updated flatten and added predicate for function identification. * Update initialTest.c * Update messyCode.c * Bug fixing, added is_functionAndBody predicate. * Update print.pl * Result after applying prettify and added collapse functions * Can identify structures and collapse them too * Can identify structures and collapse them too * Can identify structures and collapse them too * Can identify structures and collapse them too * Can identify structures and collapse them too * Update messyCode.c * Update README.md * Update prettify.pl * Update README.md * Update prettify.pl * Update messyCode.c * Update messyCode.c * Update page.html * Fix bug typedef * Update page.html * Added choices * Update c2html.pl * Update prettify.pl * Update prettify.pl * Update README.md * Update README.md * Update c2html.pl * Update c2html.pl * Added forgotten do-while structure format * Update messyCode.c * Removing unknown tokens from stream * Rename homework/81281/c2html/page.html to homework/81281/c2html/exampleCodeAndTestPage/page.html * Rename homework/81281/c2html/messyCode.c to homework/81281/c2html/exampleCodeAndTestPage/messyCode.c * Rename homework/81281/c2html/initialTest.c to homework/81281/c2html/exampleCodeAndTestPage/initialTest.c * Update prettify.pl * Can collapse all control structures and fixed comment /**/ * Can collapse all control structures and fixed comment /**/ * Can collapse all control structures and fixed comment /**/ * Can collapse all control structures and fixed comment /**/ * Can collapse all control structures and fixed comment /**/ * Fixed named of predicates * Update messyCode.c * Update page.html * Update README.md * Changed execTAB to "\s\s\s\s" * Changed execTAB to "\s\s\s\s" * Changed execTAB to "\s\s\s\s" * Update page.html * Added new tokens (forgotten operators) and added rules for them * Added new tokens (forgotten operators) and fixed some old predicates * Fixed bug with "else '\n' if (..)" in addNewLines predicate * Fixed regular expression for a string and removed token ttypesPrintF * Added clauses for handling enum and fixed handling of chars * Fixed typos * Added forgotten token to clause * Fixed "case smt :'\n'" where smt is more than one char * Fixed some bugs and divided code in modules * New code module and fixed bugs * Fixed some bugs with tabulation * Divided code in modules * Delete executeProgram.sh * Delete test.c * Initial version, still very buggy. * Finished with bug killing. * Fixed readme and added new program for tests. * Forgotten line added. * Organizing stuff in different folders. * Forgot to delete files. * Fixed typo. --- .../brainf***Interpreter/testPrograms/bigProgram.b | 32 +++++++++++++++++++++ .../brainf***Interpreter/testPrograms/input.txt | 1 + .../81281/brainf***Interpreter/testPrograms/pr.b | 21 ++++++++++++++ .../testPrograms/smallProgram.b | 33 ++++++++++++++++++++++ 4 files changed, 87 insertions(+) create mode 100644 homework/81281/brainf***Interpreter/testPrograms/bigProgram.b create mode 100644 homework/81281/brainf***Interpreter/testPrograms/input.txt create mode 100644 homework/81281/brainf***Interpreter/testPrograms/pr.b create mode 100644 homework/81281/brainf***Interpreter/testPrograms/smallProgram.b (limited to 'homework/81281/brainf***Interpreter/testPrograms') diff --git a/homework/81281/brainf***Interpreter/testPrograms/bigProgram.b b/homework/81281/brainf***Interpreter/testPrograms/bigProgram.b new file mode 100644 index 0000000..2f311a7 --- /dev/null +++ b/homework/81281/brainf***Interpreter/testPrograms/bigProgram.b @@ -0,0 +1,32 @@ +99 bottles in 1752 brainfuck instructions +by jim crawford (http://www (dot) goombas (dot) org/) +>++++++++++[<++++++++++>-]<->>>>>+++[>+++>+++<<-]<<<<+<[>[>+ +>+<<-]>>[-<<+>>]++++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[[-]>> +>>>>[[-]<++++++++++<->>]<-[>+>+<<-]>[<+>-]+>[[-]<->]<<<<<<<< +<->>]<[>+>+<<-]>>[-<<+>>]+>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<< +<[>>+>+<<<-]>>>[-<<<+>>>]++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]< +<[>+<[-]]<[>>+<<[-]]>>[<<+>>[-]]<<<[>>+>+<<<-]>>>[-<<<+>>>]+ ++++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[>+<[-]]<[>>+<<[-]]>>[< +<+>>[-]]<<[[-]>>>++++++++[>>++++++<<-]>[<++++++++[>++++++<-] +>.<++++++++[>------<-]>[<<+>>-]]>.<<++++++++[>>------<<-]<[- +>>+<<]<++++++++[<++++>-]<.>+++++++[>+++++++++<-]>+++.<+++++[ +>+++++++++<-]>.+++++..--------.-------.++++++++++++++>>[>>>+ +>+<<<<-]>>>>[-<<<<+>>>>]>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<< +[>>>+>+<<<<-]>>>>[-<<<<+>>>>]+>+<[-<->]<[[-]>>-<<]>>[[-]<<+> +>]<<<[>>+<<[-]]>[>+<[-]]++>>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]< ++<[[-]>-<]>[<<<<<<<.>>>>>>>[-]]<<<<<<<<<.>>----.---------.<< +.>>----.+++..+++++++++++++.[-]<<[-]]<[>+>+<<-]>>[-<<+>>]+>+< +[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<[>>+>+<<<-]>>>[-<<<+>>>]++++ +>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[>+<[-]]<[>>+<<[-]]>>[<<+> +>[-]]<<[[-]>++++++++[<++++>-]<.>++++++++++[>+++++++++++<-]>+ +.-.<<.>>++++++.------------.---.<<.>++++++[>+++<-]>.<++++++[ +>----<-]>++.+++++++++++..[-]<<[-]++++++++++.[-]]<[>+>+<<-]>> +[-<<+>>]+++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[[-]++++++++++. +>+++++++++[>+++++++++<-]>+++.+++++++++++++.++++++++++.------ +.<++++++++[>>++++<<-]>>.<++++++++++.-.---------.>.<-.+++++++ +++++.++++++++.---------.>.<-------------.+++++++++++++.----- +-----.>.<++++++++++++.---------------.<+++[>++++++<-]>..>.<- +---------.+++++++++++.>.<<+++[>------<-]>-.+++++++++++++++++ +.---.++++++.-------.----------.[-]>[-]<<<.[-]]<[>+>+<<-]>>[- +<<+>>]++++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[[-]++++++++++.[ +-]<[-]>]<+<] diff --git a/homework/81281/brainf***Interpreter/testPrograms/input.txt b/homework/81281/brainf***Interpreter/testPrograms/input.txt new file mode 100644 index 0000000..341cc98 --- /dev/null +++ b/homework/81281/brainf***Interpreter/testPrograms/input.txt @@ -0,0 +1 @@ +example 123 diff --git a/homework/81281/brainf***Interpreter/testPrograms/pr.b b/homework/81281/brainf***Interpreter/testPrograms/pr.b new file mode 100644 index 0000000..1dce918 --- /dev/null +++ b/homework/81281/brainf***Interpreter/testPrograms/pr.b @@ -0,0 +1,21 @@ +Calculate the value 256 and test if it's zero +If the interpreter errors on overflow this is where it'll happen +++++++++[>++++++++<-]>[<++++>-] ++<[>-< + Not zero so multiply by 256 again to get 65536 + [>++++<-]>[<++++++++>-]<[>++++++++<-] + +>[> + # Print "32" + ++++++++++[>+++++<-]>+.-.[-]< + <[-]<->] <[>> + # Print "16" + +++++++[>+++++++<-]>.+++++.[-]< +<<-]] >[> + # Print "8" + ++++++++[>+++++++<-]>.[-]< +<-]< +# Print " bit cells\n" ++++++++++++[>+++>+++++++++>+++++++++>+<<<<-]>-.>-.+++++++.+++++++++++.<. +>>.++.+++++++..<-.>>- +Clean up used cells. +[[-]<] diff --git a/homework/81281/brainf***Interpreter/testPrograms/smallProgram.b b/homework/81281/brainf***Interpreter/testPrograms/smallProgram.b new file mode 100644 index 0000000..e080b7f --- /dev/null +++ b/homework/81281/brainf***Interpreter/testPrograms/smallProgram.b @@ -0,0 +1,33 @@ +[ This program prints Sierpinski triangle on 80-column display. ] + > + + + + + + + [ < + + + + + + + + + + + > - ] > + + + + + + + + + + [ > + + + + + + < - ] > + > + + > > > + > + > > + < + < < < < < < < < + < [ - [ - > + < + ] > [ - < + > > > . < < ] > > > + [ [ + - > + + + + + + + + + + [ > + + + + + < - ] > + . < < [ - > + < + ] + > [ - > + + + + + + + + + + + < < + > ] > . [ + - ] > ] + ] + < < < [ - [ + - > + < ] + > [ + - < + > > > - [ - > + < ] + + > + [ - < - > ] < < + < ] < < < < ] + + + + + + + + + + + . + + + . [ - ] < ] + + + + + + * * * * * M a d e * B y : * N Y Y R I K K I * 2 0 0 2 * * * * * -- cgit v1.3.1-26-gb76a