Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: parse problem
Pages: [1] Print
Author Topic: parse problem  (Read 263 times)
parser
Guest


Email
parse problem
« on: August 07, 2005, 04:11:23 PM »

I don't understand why it does parse only partially by extracting only y and not z :

input: {x op1 y op2 z}

rules-partial: [
thru " op1 " copy text1 to " op2 " (ask text1) thru " op2 " copy text2 to newline (ask text2)
(probe text1 probe text2 ask "")
]

parse input rules-partial  

-----------
Pasting above in the console it only gives me y and not z:


>> input: {x op1 y op2 z}
== "x op1 y op2 z"
>>
>> rules-partial: [
[    thru " op1 " copy text1 to " op2 " (ask text1) thru " op2 " copy text2 to newline
 (ask text2)
[    (probe text1 probe text2 ask "")
[    ]
== [
    thru " op1 " copy text1 to " op2 " (ask text1) thru " op2 " copy text2 to newline
(ask text2)
    (probe text1 probe text...
>>
>> parse input rules-partial
y== false
>>
 
Logged
CarlRead
Full Member
***
Offline Offline

Posts: 105


View Profile
parse problem
« Reply #1 on: August 08, 2005, 05:05:44 AM »

I don't see a newline in input's string, so I assume that's your problem.  Either add one.  ie...
Code:
input: {x op1 y op2 z^/}
or instead of using to newline, use to end.

Hope that helps.
 
Logged

- Carl Read
parser
Guest


Email
parse problem
« Reply #2 on: August 08, 2005, 09:33:41 AM »

Hi, thanks but I tried with end and it does give the same result

>> input: {x op1 y op2 z}
== "x op1 y op2 z"
>>
>> rules-partial: [
[    thru " op1 " copy text1 to " op2 " (ask text1) thru " op2 " copy text2 to end (as
k text2)
[    (probe text1 probe text2 ask "")
[    ]
== [
    thru " op1 " copy text1 to " op2 " (ask text1) thru " op2 " copy text2 to end (ask
 text2)
    (probe text1 probe text2 as...
>> parse input rules-partial
y== false
>>
Logged
Gabriele
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
parse problem
« Reply #3 on: August 09, 2005, 09:42:22 AM »

Please note that you are redefining INPUT, and using ASK. See the source of ASK:

Code:
ask: func [
   "Ask the user for input."
   question [series!] "Prompt to user"
   /hide "mask input with *"
][
   prin question
   trim either hide [input/hide] [input]
]

Anyway:

Code:
>> parse/all "x op1 y op2 z" [thru "op1" copy text1 to "op2" "op2" copy text2 to end]
== true
>> text1
== " y "
>> text2
== " z"
Logged
parser
Guest


Email
parse problem
« Reply #4 on: August 10, 2005, 12:10:54 AM »

Thanks a lot both, it has solved my problem Smiley
Logged
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: parse problem
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 20, 2008, 10:31:39 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2287 Posts in 593 Topics by 3727 Members
Latest Member: Maximinioles

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc