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

> 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:[EMAIL PROTECTED]
> 
> -- 
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the 
> subject, without the quotes.

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to