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

simple parse and copy question

 [1/4] from: sharriff:aina:med-iq at: 4-Oct-2000 13:24


>> help copy
USAGE: COPY value /part range /deep considering: parse page [thru <title> copy text to </title> ] copy is evaluted towars the RIGHT side, copies values into WORD! text am I to take this as it is? can someone explain exactly why this particular example works this way. regards Sharriff Aina med.iq information & quality in healthcare AG

 [2/4] from: brett:codeconscious at: 5-Oct-2000 0:36


The "copy" you see in the parse rule is not the same as the copy at the command line. Parse rules are made up from a dialect specific to parse. That is, the code you find in a parse rule is not executed like ordinary script, it is instead interpreted by the parse function. When the parse function encounters the word "copy" in a parse rule it applies its own specific meaning - just like you could if you had a function that processed words in a block. Check out the documentation on parse and you will find that the result of using copy (in parse) is to copy the input stream from the current position for as long as the next match pattern is valid. In contrast, the bits of code you find in a parse rule between a "(" and a ) are normal rebol commands. This allows you to have the power of rebol script from within parse. Another thing you will see in parse rules is a set-word like "here-i-am:". Again, when parse encounters this set-word it applies its own specific meaning, in this case it is to assign the word "here-i-am" to the current location of the input-stream. See the documentation for an example of this use. Hope that explains it. Brett.

 [3/4] from: sharriff:aina:med-iq at: 4-Oct-2000 15:04


>Parse rules are made up from a dialect specific to parse. That is, the >"code" you find in a parse rule is not executed like ordinary script, it
is
>instead interpreted by the parse function. When the parse function >encounters the word "copy" in a parse rule it applies its own specific >meaning - just like you could if you had a function that processed words
in
>a block.
Thanks Brett, saw the same explanation in the users guide, guess I should do some more RTFM Sharriff Aina med.iq information & quality in healthcare AG

 [4/4] from: joel::neely::fedex::com at: 4-Oct-2000 10:16


Hi, Sharriff... [Sharriff--Aina--med-iq--de] wrote:
> >> help copy > USAGE:
<<quoted lines omitted: 4>>
> am I to take this as it is? can someone explain exactly why this > particular example works this way.
The answer is that help copy gives you the normal usage of copy as a word in standard REBOL. However, inside a setting such as parse something [ ... copy bletch somerulepart ...] the word copy is used as a part of the parsing dialect. (See the new docs, chapter 14, for an explanation -- esp. pp. 14-14 and 14-27.) In that dialect (using the above partial example) the variable following the word copy receives a copy of whatever matches the following somerulepart . The help (or ? variant) function only deals with top-level usage of words, which is also why you get
>> ? thru
No information on thru (word has no value) for another word in the parsing dialect. HTH! -jn- -- ; Joel Neely [joel--neely--fedex--com] 901-263-4460 38017/HKA/9677 REBOL [] print to-string debase decompress #{ 789C0BCE0BAB4A7176CA48CAB53448740FABF474F3720BCC B6F4F574CFC888342AC949CE74B50500E1710C0C24000000}

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted