Minor correction to the code: The comment rule needs to accept the case when it is the 
last line in a script and the line is not terminated:

   #";" [thru newline | to end] new: 

The color and clean scripts should also do this. I'll correct them in the copies that 
I post to the script library.

-Carl


At 5/27/00 02:35 PM -0700, you wrote:
>REBOL [
>    Title: "Parse REBOL Source"
>    Author: "Carl Sassenrath"
>    File:  %parse-source.r
>    Date:  27-May-2000
>    Purpose: {Example parser for REBOL source code.}
>    Category: [script util text 2]
>]
>
>parse-source: func [
>    "Parse REBOL source code."
>    text /local str new
>][
>    parse text blk-rule: [
>        some [  ; repeat until done
>            str:
>            newline |
>            #";" thru newline new: (probe copy/part str new) |
>            [#"[" | #"("] blk-rule |
>            [#"]" | #")"] |
>            skip (set [value new] load/next str  probe :value) :new
>        ]
>    ]
>]
>
>parse-source read %parse-source.r
> 

Reply via email to