[REBOL] Parser seems to have bug - different results on multiple calls. Re:

2000-07-03 Thread dan

not bad...for whatever it's worth, it opens up the Gateway catalog file at 
the top of my screen behind the taskbar, so I can't easily turn it 
off...may be a unique problem with my system.  ds
At 04:25 PM 7/1/00 +1000, you wrote:
Howdy,

I've been having trouble with strange results in the parser. Rebol seems to
cache the parse rules, which seems like a good idea, but I've found
something unexpected.

If you copy the code below and paste it (Win or call script in Linux) into
your Rebol session you can see how the three calls to parse will change
results even though it is the same rule and data.

If in the same session you repeat the process  you will get the same results
again - that is, the first line is right again!

Have I done something wrong?

BTW, Wouldn't it be nice if there was a parse /explain that would show the
"plan" or description of the state machine that will be used for parsing, or
whatever is used. I'm always getting confused on the parse syntax. Having
this would make it easier for me anyway!

Appears in
REBOL/View 0.9.9.3.1 1-Jun-2000
REBOL/Core 2.3.0.3.1
on Windows NT 4 SP 4

Brett Handley

 ; Here starts the code

 only-string: func[ s [any-string! none!] ][ either s [s][{}]]

 quoted-data-rule: [
(cell-data: {} Print "Setting the cell-data value") ; This seems to
get ignored on subsequent calls of parse.
{"} copy data to {"} {"} (append cell-data only-string data)
any [
{"} copy data to {"} {"} (append cell-data rejoin [{"}
only-string data])
]
 ]
 parse/all {"""."} quoted-data-rule  ; This looks ok.
 print cell-data ;

 parse/all {"""Hrmm."} quoted-data-rule  ; This is not right.
 print cell-data ;

 parse/all {"""oi!"} quoted-data-rule  ; Bugger.
 print cell-data ;





[REBOL] Parser seems to have bug - different results on multiple calls. Re:

2000-07-01 Thread bhandley

How embarassing. Sent the wrong code. Here is the actual problem code.

only-string: func[ s [any-string! none!] ][ either s [s][{}]]

quoted-data-rule: [
   (cell-data: {} print "--init-line--") ; This seems to be ignored on
subsequent calls of parse.
   {"} copy data to {"} {"} (append cell-data only-string data)
   any [
   {"} copy data to {"} {"} (append cell-data rejoin [{"}
only-string data])
   ]
]
parse/all {"""Mutter."} quoted-data-rule  ; This looks ok.
print cell-data ;

parse/all {"""Mutter."} quoted-data-rule  ; This is not right.
print cell-data ;

parse/all {"""Mutter."} quoted-data-rule  ; Bugger.
print cell-data ;





[REBOL] Parser seems to have bug - different results on multiple calls. Re:(2)

2000-07-01 Thread allenk

Hi Brett,

change
cell-data: {}
to
cell-data: copy {}

This ensures you get a new empty string each call.

Cheers,

Allen K

- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, July 01, 2000 4:48 PM
Subject: [REBOL] Parser seems to have bug - different results on multiple
calls. Re:


 How embarassing. Sent the wrong code. Here is the actual problem code.

 only-string: func[ s [any-string! none!] ][ either s [s][{}]]

 quoted-data-rule: [
(cell-data: {} print "--init-line--") ; This seems to be ignored on
 subsequent calls of parse.
{"} copy data to {"} {"} (append cell-data only-string data)
any [
{"} copy data to {"} {"} (append cell-data rejoin [{"}
 only-string data])
]
 ]
 parse/all {"""Mutter."} quoted-data-rule  ; This looks ok.
 print cell-data ;

 parse/all {"""Mutter."} quoted-data-rule  ; This is not right.
 print cell-data ;

 parse/all {"""Mutter."} quoted-data-rule  ; Bugger.
 print cell-data ;







[REBOL] Parser seems to have bug - different results on multiple calls. Re:(4)

2000-07-01 Thread Al . Bri

 But, now I'm confused. Why is that different to what I had? Or, why didn't
I get a new empty string each call previously?

It's one of the differences Rebol has with other languages. When you assign
a string to a word, like this:
s: ""
You're literally assigning 's to the string just after the 's in the
above line. Therefore that string, just after the "s:" is where the contents
of the string refered to by 's reside.
By using the 'copy, as in:
s: copy ""
you get a fresh copy of the next thing after the 'copy word, into 's.\

The colon ":" is the set-word operator, which is literally:
set the word to the left to point to the right.
Which is not quite assignment in conventional languages.

I hope that helps!

Andrew Martin
Unique Rebol...
ICQ: 26227169
http://members.xoom.com/AndrewMartin/
--




[REBOL] Parser seems to have bug - different results on multiple calls. Re:(5)

2000-07-01 Thread bhandley

 The colon ":" is the set-word operator, which is literally:
 set the word to the left to point to the right.
 Which is not quite assignment in conventional languages.
 
 I hope that helps!
 

I think it will.hopefully. :\
Thanks.

Brett.




[REBOL] Parser seems to have bug - different results on multiple calls. Re:(4)

2000-07-01 Thread ingo

Hi Brett,

maybe this little func 'll show you what's happening ...

test: func [] [
s1: "" 
s2: copy "" 
append s1 "Hi, I'm changed" 
append s2 "I'm not ..." 
source test 
]

 test
test: func [][
s1: "Hi, I'm changed" 
s2: copy "" 
append s1 "Hi, I'm changed" 
append s2 "I'm not ..." 
source test
]

You see, s1 has literally been changed in the source-code, 
s2 has not. (It's one of the Rebol traps everyone has to
fall into once.)


I hope this helps

Ingo
 

Once upon a time [EMAIL PROTECTED] spoketh thus:
 Thanks Allen. That certainly does work.
 
 But, now I'm confused. Why is that different to what I had? Or, why didn't I
 get a new empty string each call previously?
 
 Brett.

--  _ ._
ingo@)|_ /|  _| _  We ARE all ONE   www._|_o _   _ ._ _  
www./_|_) |o(_|(/_  We ARE all FREE ingo@| |(_|o(_)| (_| 
 ._|  ._|




[REBOL] Parser seems to have bug - different results on multiple calls. Re:(5)

2000-07-01 Thread bhandley

picks jaw off ground/

Thanks Ingo,
I'll just have to go away and reassemble some brain patterns...

Brett.

- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, July 02, 2000 12:48 AM
Subject: [REBOL] Parser seems to have bug - different results on multiple
calls. Re:(4)


 Hi Brett,

 maybe this little func 'll show you what's happening ...

 test: func [] [
 s1: ""
 s2: copy ""
 append s1 "Hi, I'm changed"
 append s2 "I'm not ..."
 source test
 ]

  test
 test: func [][
 s1: "Hi, I'm changed"
 s2: copy ""
 append s1 "Hi, I'm changed"
 append s2 "I'm not ..."
 source test
 ]

 You see, s1 has literally been changed in the source-code,
 s2 has not. (It's one of the Rebol traps everyone has to
 fall into once.)


 I hope this helps

 Ingo


 Once upon a time [EMAIL PROTECTED] spoketh thus:
  Thanks Allen. That certainly does work.
 
  But, now I'm confused. Why is that different to what I had? Or, why
didn't I
  get a new empty string each call previously?
 
  Brett.

 --  _ ._
 ingo@)|_ /|  _| _  We ARE all ONE   www._|_o _   _ ._ _
 www./_|_) |o(_|(/_  We ARE all FREE ingo@| |(_|o(_)| (_|
  ._|  ._|





[REBOL] Parser seems to have bug - different results on multiple calls. Re:(5)

2000-07-01 Thread bhandley

Some time back. Brian Hawley referred to a discussion on Contexts. Which at
first I could not find.
However spurred on by my misunderstanding of what Rebol is doing, I made a
renewed attempt to find the discussion and was successful.

See the thread "Contexts, and related ideas" in...
http://www.rebol.org/userlist/html/threads-21.html

Brett.