Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

BNF grammar of REBOL for code "obfuscator"

 [1/3] from: geza67::freestart::hu at: 17-Dec-2001 16:30


Hello REBOLers, I would like to write a code "obfuscator" (C-ish intention, isn't it ;-)) ) for REBOL. Tha main idea behind is to have a custom loader by 'COMPRESSing the program code and 'DECOMPRESS it on load, like this: - the "packager" REBOL line: write/binary %someprog.bin compress read %someprog.r - the shell loader (WinDOS .BAT file): rebol.exe -s --noinstall --do "do decompress read/binary %%someprog.bin quit" To get the unnecessary overhead data out of the script I would like to - strip the header to the simplest "REBOL []" form - extinct one-line and block comments - reduce tabulation and blank lines to single whitespace My first approach to detect the end of the REBOL header did not work: I just cannot keep track of the nested block levels in parse rules :-( I also stucked at detecting comment boundaries - to detect one-line comments whether they are _real_ comments or just ";" characters buried within a string (both "" and {} delimited) - detect 'COMMENT blocks (reprise of the previously mentioned detection problem for nested blocks) Do you have an exact BNF notation (or directly 'PARSE rules) of the REBOL language ? I searched the library but even %color-code.r is very spartanian and does not destructure a REBOL script this way (although its syntax coloring purpose might have suggested so). Thanx for your commitment of ideas! -- Best regards, Geza Lakner MD mailto:[geza67--freestart--hu]

 [2/3] from: sterling:rebol at: 17-Dec-2001 10:07


No need to PARSE it yourself. :) REBOL knows all this stuff on it's own so let it do the work. ? load ... REFINEMENTS: /header -- Includes REBOL header object if present. /next -- Load the next value only. Return block with value and new position. /library -- Force file to be a dynamic library. (Command version) /markup -- Convert HTML and XML to a block of tags and strings. /all -- Load all values. Does not evaluate REBOL header. Play around with load/header and load/next. The /all refinement is recommended if you are working with an unknown script so that no evaluation will happen. To remove comments, just let REBOL remove them for you and try: save %file2.r load %.file.r I'm sure you'll get some more input on this from others too. Sterling

 [3/3] from: rotenca:telvia:it at: 17-Dec-2001 20:37


Hi Geza, look at http://www.rebol.com/docs/core25.html#section-7 and http://www.reboltech.com/library/html/parse-code.html --- Ciao Romano