Parsing with 2 conditions
[1/9] from: richard::coffre::francetelecom::com at: 10-Apr-2002 11:03
Hi,
Another parsing questions.
1st question :
The following instruction works :
if parse/all ligne [thru "Symbol" to end]
why the next one doesn't work :
if parse/all ligne [ "Symbol" ]
2nd question :
I have the instruction "if parse/all ligne [thru "Symbol" to end]" to look
for the word Symbol in a string. How can I do to look for Symbol and Frame
at the same time ?
TIA
Richard Coffre
France Telecom Orbiscom
T=E9l. : 01 47 61 46 28
[2/9] from: brett:codeconscious at: 10-Apr-2002 20:05
Bonsoir,
> The following instruction works :
> if parse/all ligne [thru "Symbol" to end]
> why the next one doesn't work :
> if parse/all ligne [ "Symbol" ]
First let's look END. END is like asking the question "Are we at the end?"
>> parse/all {} [end]
== true
>> parse/all {x} [end]
== false
In these cases, ["Symbol"] is the same as ["Symbol" END]:
>> parse/all {} []
== true
>> parse/all {} [end]
== true
>> parse/all {x} []
== false
>> parse/all {x} [end]
== false
>> parse/all {x} ["x"]
== true
>> parse/all {x} ["x" end]
== true
["Symbol"] is like "Is there a 'Symbol' here?"
>> parse/all {Symbol} ["Symbol"]
== true
>> parse/all {xSymbol} ["Symbol"]
== false
>> parse/all {xSymbol} ["x" "Symbol"]
== true
>> parse/all {xSymbol} [skip "Symbol"]
== true
>> parse/all {Symbolx} ["Symbol"]
== false
TO ... Is like saying "Keep going until you reach...":
>> parse/all {abcdef} [to "d" "def" end]
== true
>> parse/all {abcdef} [to "e" "ef" end]
== true
THRU ... Is like saying "Keep going until you reach the end of ..."
>> parse/all {abcdef} [thru "e" "f"]
== true
>> parse/all {abcdef} [thru "ef"]
== true
SKIP - "Advance by one position"
>> parse/all {abcdef} [to "e" skip "f" end]
== true
TO END is like "Keep going to the end"
>> parse/all {x} [to end]
== true
>> parse/all {xxxxxx} [to end]
== true
>> parse/all {x} [to end "x"]
== false
So after all that
[thru "Symbol" to end]
is like saying
"Keep going until you reach the end of 'Symbol'
(that is - after the 'l'), and then keep going to the end."
Whereas
[ "Symbol" ]
is simply like saying
"Is there 'Symbol' right here, and if is advance throught it.
Are we now at the end?"
> 2nd question :
> I have the instruction "if parse/all ligne [thru "Symbol" to end]" to look
> for the word Symbol in a string. How can I do to look for Symbol and Frame
> at the same time ?
>> parse/all {xxxSymbolxxx} [thru "Symbol" to end]
== true
>> parse/all {xxxFramexxx} [thru "Symbol" to end]
== false
>> parse/all {xxxFramexxx} [ [thru "Symbol" | thru "Frame"] to end]
== true
Also have a look at:
http://www.codeconscious.com/rebol/parse-tutorial.html
I hope this helps.
Brett Handley.
[3/9] from: lmecir:mbox:vol:cz at: 10-Apr-2002 13:51
Hi Richard,
you can try e.g.:
parse/all ligne [start: thru "Symbol" :start thru "Frame" to end]
, which tests whether both words are present in the text somewhere in any
order.
Cheers
L
----- Original Message -----
From: "COFFRE Richard FTO"
Hi,
Another parsing questions.
1st question :
The following instruction works :
if parse/all ligne [thru "Symbol" to end]
why the next one doesn't work :
if parse/all ligne [ "Symbol" ]
2nd question :
I have the instruction "if parse/all ligne [thru "Symbol" to end]" to look
for the word Symbol in a string. How can I do to look for Symbol and Frame
at the same time ?
TIA
Richard Coffre
France Telecom Orbiscom
Tél. : 01 47 61 46 28
[4/9] from: richard:coffre:francetelecom at: 10-Apr-2002 14:17
tx for your answer.
-----Message d'origine-----
De : Anton [mailto:[anton--lexicon--net]]
Envoy=E9 : mercredi 10 avril 2002 13:21
=C0 : [rebol-list--rebol--com]
Objet : [REBOL] Re: Parsing with 2 conditions
1) What's in your ligne?
'parse must get to the end of your string to
return true.
>> ligne: "Symbol"
== "Symbol"
>> parse ligne ["Symbol"]
== true
It works for me... but maybe you have something like:
>> parse "Symbol " ["Symbol"]
== false
2) Does this help?
>> parse "----Symbol---FraSymFrameSymbol---Frame" [some ["Symbol" |
Frame
| skip]]
== true
Anton.
[5/9] from: anton:lexicon at: 10-Apr-2002 21:20
1) What's in your ligne?
'parse must get to the end of your string to
return true.
>> ligne: "Symbol"
== "Symbol"
>> parse ligne ["Symbol"]
== true
It works for me... but maybe you have something like:
>> parse "Symbol " ["Symbol"]
== false
2) Does this help?
>> parse "----Symbol---FraSymFrameSymbol---Frame" [some ["Symbol" | "Frame"
| skip]]
== true
Anton.
[6/9] from: richard:coffre:francetelecom at: 10-Apr-2002 14:14
Thanks a lot for this complete explanation. It's clear now.
-----Message d'origine-----
De : Brett Handley [mailto:[brett--codeconscious--com]]
Envoy=E9 : mercredi 10 avril 2002 12:05
=C0 : [rebol-list--rebol--com]
Objet : [REBOL] Re: Parsing with 2 conditions
Bonsoir,
> The following instruction works :
> if parse/all ligne [thru "Symbol" to end]
> why the next one doesn't work :
> if parse/all ligne [ "Symbol" ]
First let's look END. END is like asking the question "Are we at the end?"
>> parse/all {} [end]
== true
>> parse/all {x} [end]
== false
In these cases, ["Symbol"] is the same as ["Symbol" END]:
>> parse/all {} []
== true
>> parse/all {} [end]
== true
>> parse/all {x} []
== false
>> parse/all {x} [end]
== false
>> parse/all {x} ["x"]
== true
>> parse/all {x} ["x" end]
== true
["Symbol"] is like "Is there a 'Symbol' here?"
>> parse/all {Symbol} ["Symbol"]
== true
>> parse/all {xSymbol} ["Symbol"]
== false
>> parse/all {xSymbol} ["x" "Symbol"]
== true
>> parse/all {xSymbol} [skip "Symbol"]
== true
>> parse/all {Symbolx} ["Symbol"]
== false
TO ... Is like saying "Keep going until you reach...":
>> parse/all {abcdef} [to "d" "def" end]
== true
>> parse/all {abcdef} [to "e" "ef" end]
== true
THRU ... Is like saying "Keep going until you reach the end of ..."
>> parse/all {abcdef} [thru "e" "f"]
== true
>> parse/all {abcdef} [thru "ef"]
== true
SKIP - "Advance by one position"
>> parse/all {abcdef} [to "e" skip "f" end]
== true
TO END is like "Keep going to the end"
>> parse/all {x} [to end]
== true
>> parse/all {xxxxxx} [to end]
== true
>> parse/all {x} [to end "x"]
== false
So after all that
[thru "Symbol" to end]
is like saying
"Keep going until you reach the end of 'Symbol'
(that is - after the 'l'), and then keep going to the end."
Whereas
[ "Symbol" ]
is simply like saying
"Is there 'Symbol' right here, and if is advance throught it.
Are we now at the end?"
> 2nd question :
> I have the instruction "if parse/all ligne [thru "Symbol" to end]" to look
> for the word Symbol in a string. How can I do to look for Symbol and Frame
> at the same time ?
>> parse/all {xxxSymbolxxx} [thru "Symbol" to end]
== true
>> parse/all {xxxFramexxx} [thru "Symbol" to end]
== false
>> parse/all {xxxFramexxx} [ [thru "Symbol" | thru "Frame"] to end]
== true
Also have a look at:
http://www.codeconscious.com/rebol/parse-tutorial.html
I hope this helps.
Brett Handley.
[7/9] from: richard:coffre:francetelecom at: 10-Apr-2002 14:49
Thanks you for your answer but it doesn't work.
A good solution is given by Brett :
parse/all {xxxFramexxx} [ [thru "Symbol" | thru "Frame"] to end]
-----Message d'origine-----
De : Ladislav Mecir [mailto:[lmecir--mbox--vol--cz]]
Envoy=E9 : mercredi 10 avril 2002 13:51
=C0 : [rebol-list--rebol--com]
Objet : [REBOL] Re: Parsing with 2 conditions
Hi Richard,
you can try e.g.:
parse/all ligne [start: thru "Symbol" :start thru "Frame" to end]
, which tests whether both words are present in the text somewhere in any
order.
Cheers
L
----- Original Message -----
From: "COFFRE Richard FTO"
Hi,
Another parsing questions.
1st question :
The following instruction works :
if parse/all ligne [thru "Symbol" to end]
why the next one doesn't work :
if parse/all ligne [ "Symbol" ]
2nd question :
I have the instruction "if parse/all ligne [thru "Symbol" to end]" to look
for the word Symbol in a string. How can I do to look for Symbol and Frame
at the same time ?
TIA
Richard Coffre
France Telecom Orbiscom
T=E9l. : 01 47 61 46 28
[8/9] from: tomc:darkwing:uoregon at: 10-Apr-2002 9:06
just nitpicking :)
Ladislav's rule does "look for Symbol and Frame at the same time"
it does not "look for Symbol or Frame at the same time"
On Wed, 10 Apr 2002, COFFRE Richard FTO wrote:
[9/9] from: richard:coffre:francetelecom at: 11-Apr-2002 8:51
Thanks a lot for this detail
-----Message d'origine-----
De : Tom Conlin [mailto:[tomc--darkwing--uoregon--edu]]
Envoy=E9 : mercredi 10 avril 2002 18:06
=C0 : ['rebol-list--rebol--com']
Objet : [REBOL] Re: Parsing with 2 conditions
just nitpicking :)
Ladislav's rule does "look for Symbol and Frame at the same time"
it does not "look for Symbol or Frame at the same time"
On Wed, 10 Apr 2002, COFFRE Richard FTO wrote: