Binary to Autoprogram converter - Printable Version +- Forums - Open Redstone Engineers (https://forum.openredstone.org) +-- Forum: Off-Topic (https://forum.openredstone.org/forum-4.html) +--- Forum: Programming (https://forum.openredstone.org/forum-8.html) +--- Thread: Binary to Autoprogram converter (/thread-5843.html) |
Binary to Autoprogram converter - Magic :^) - 02-19-2015 So, I've finished making the autoprogram templater. I'll comment it better and clean up the code later, but it works as intended right now so I'm uploading it. TODO: add more error messages and warnings and stuff for template syntax errors TODO: general cleanup. (more comments, less stupid code, remove references to nonexistent methods.) TODO: support parsing hex files to support writing to hex rom. TODO: add support for basic escape characters like \n TODO: allow (0){ ... } declarations. TODO: have a check for endless recursive template calling. e.g. check for stoopid definitions. usage: binScripter.py (sourcefile) (templatefile) (outputfile) basic syntax etc: Here's the code: (v1.5) https://github.com/MagicalGentleman/binScripter (This is a python 3 program) RE: Binary to Autoprogram converter - Phase - 02-24-2015 Thank you for using Python 3. I was making a language in Python (https://github.com/Phasesaber/Flow), but I found Java to be easier with OOP. http://pbin.in/SometimesILikeMen RE: Binary to Autoprogram converter - Magic :^) - 02-26-2015 Code updated! ... It's a bit easier to use now xD RE: Binary to Autoprogram converter - Magic :^) - 03-09-2015 Ah it wasn't mentioned earlier, but there is some nicer commenting syntax now. You just use Code: (0){ ... } Also, here's something you can include at the top of your file to make templating a bit easier: Code: (0){ I've also decided to use python's sys.setrecursionlimit() to prevent a template file from being trapped in an infinite recursive loop and outputting garbage. (If this happens, it is the template writer's fault for not iterating through the binary source while using a recursive call.) RE: Binary to Autoprogram converter - Magic :^) - 03-12-2015 k so I'm going to push an update later that will stop this: Code: (destructiveRecursive){[destructiveRecursive]} added a limit so idiots don't try the above code to write infinitely to a text file. you can change that by using -r or --recursivelimit, followed by a number. The default is 512 atm. (The above is a command line arg btw) I'll update once I find a nice way to handle the exception this throws. EDIT: done. RE: Binary to Autoprogram converter - Magic :^) - 03-12-2015 New feature added! You can now reference a template instead of a string in the ~var type declarations. for example: Code: (exampleTemplate){"this is basically called conditionally now.\n"} no variables referencing variables though. If you really needed to, you could always call a template which then referenced the variable from there. EDIT: I may add support for vars referencing vars at some point though... The way I would do it would also clean my code up a bit. hmn... RE: Binary to Autoprogram converter - Magic :^) - 04-05-2015 I have finally got an actual autoprogram conversion example ![]() I have taken the opportunity to make a short templating library for standard torch rom, so the actual part that describes your rom's properties looks like this: Code: (4){ RE: Binary to Autoprogram converter - Nickster258 - 04-06-2015 Keep in mind: autoprogram was rewritten in java for the 1.8 update so some background stuff may change. RE: Binary to Autoprogram converter - Magic :^) - 04-08-2015 yeah, the script parser is general purpose so I don't need to worry about that. I can use this for pretty much anything that needs repetitive work. It just happens that I started this project with autoprogram in mind ![]() also I can abstract the keywords used by autoprogram with a library style of script writing so changes can be made pretty easily to existing scripts. |