elikaski / BF-it

A C-like language to Brainfuck compiler, written in Python
MIT License
121 stars 11 forks source link

Add x-bit ints #66

Closed abhra2020-smart closed 3 years ago

abhra2020-smart commented 3 years ago

Add customizability to how much bit ints there are

NeeEoo commented 3 years ago

The interpreter should be able to receive the bit size from a parameter on the interpreter function. So that you can pass a value from the compiler with for example --interpreter-bits 16

NeeEoo commented 3 years ago

I think you forgot to add the expression to the - instruction

elikaski commented 3 years ago

Please make the interpreter receive an optional flag indicating the cell bit size :)

NeeEoo commented 3 years ago

When this gets merged (after the changes) i will make some library functions that are related to this and are very much needed.

NeeEoo commented 3 years ago

You should pass the bits variable to the brainfuck function. And in the definition https://github.com/elikaski/BF-it/blob/735f276cef40e0e567a473cf8871b11a4ca70180/Interpreter.py#L27 You should add , bits=8 so you can call this function from another file. Since you can run the compiled code from the compiler

abhra2020-smart commented 3 years ago

Made changes.

abhra2020-smart commented 3 years ago

That was a misclick

elikaski commented 3 years ago

Excellent! Thank you :) You missed 2 things that I mentioned. I tagged you in them so you will see They are:

  1. Adding nargs=1 to the -b argument
  2. Adding the bits calculation to the "-" instruction, similar to the "+" instruction Currently the value "255" is hard-coded, it should be 2 ** bits - 1

Please add these and I'll merge :)

elikaski commented 3 years ago

Excellent! Thank you :) You missed 2 things that I mentioned. I tagged you in them so you will see They are:

  1. Adding nargs=1 to the -b argument
  2. Adding the bits calculation to the "-" instruction, similar to the "+" instruction Currently the value "255" is hard-coded, it should be 2 ** bits - 1

Please add these and I'll merge :)

(for some reason I can't tag you, so I kept these conversations as "unresolved")

abhra2020-smart commented 3 years ago

Hopefully the final commit has been made

NeeEoo commented 3 years ago

I think that everything looks good. Only thing is the file opening. The old version used with open(...) as f:

NeeEoo commented 3 years ago

The f.close() is unnecessary since the with statement does that automatically

elikaski commented 3 years ago

Merged, thank you :)