Giter Club home page Giter Club logo

budivelnyk's People

Contributors

arseniiv avatar formicant avatar wadimiusz avatar zabolekar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

budivelnyk's Issues

Emit single instructions for groups of opcodes

Would be nice to emit a single instruction for each homogeneous group of +, -, < or >. As of now repeated instructions are emitted.

Also it might be an interesting challenge to add recognition of some of these:

  • clearing a cell value to zero (if positive) via [-] or simple equivalents (it is the user’s fault if they write [-+-] and it doesn’t optimize);
  • copying a cell value into cells;
  • addition or subtraction of two cells;
  • multiplication by a constant;
  • multiplication of two cells;
  • floor division or modulus of two ceils

—probably the later the lesser a gain.

End of stream at input isn’t tested

Something definite should be happening at EOF when , is run, and be tested.

Cf. https://esolangs.org/wiki/Brainfuck#EOF:

EOF is a controversial issue. Many implementations return 0, some return -1, and several notable brainfuck programmers suggest that on EOF the memory cell should be left as-is, without modification. In the original distribution the compiler left the cell unchanged, while the interpreter used the EOF from C which, strictly speaking, could be any negative integer, but which usually is -1 (which, in the case of byte-sized cells, ends up as 255).

and https://esolangs.org/wiki/Brainfuck#EOF_2:

An interpreter should normally either return Zero or leave the cell unchanged on EOF.

The Zero option matches the brainfuck language in that the only conditional in brainfuck is a comparison with zero. Using this form, in theory, allows slightly shorter code. For eight bit cells the "leave the cell untouched" matches the C/Unix read(2) system call in that the character memory will be left unchanged on EOF. For Unix the EOF (or error) condition is signalled by the return value, which is lost with BF. If the interpreter's cells are more than eight bits the "unchanged cell" can safely handle binary data. If the cells are eight bit or the interpreter sets the cells to zero on EOF binary data cannot be handled.

For a brainfuck program this means that ASCII data+EOF should be read using a [-], construct (or similar). Binary input should, probably, be read using a construct of the form [-]-,. This requires that input bytes are in the range 0..255 when the cell size exceeds eight bits.

Note: It is strongly recommended that an interpreter be configurable to all three normal form of EOF (Zero, minus one and unchanged).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.