r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Parse] Discussion of PARSE dialect

Graham
21-Sep-2005
[400]
tricky :)
Geomol
21-Sep-2005
[401x3]
>> parse [1 1 1 1] [1 4 1]
== true
>> parse [1 1 1 1] [1 3 1]
== false
Putting numbers in the rule block indicates number of something. 
So [1 4 1] means 1 to 4 times 1.
Easier to see this way:
>> parse [a a a a] [1 4 'a]
== true
>> parse [a a a a] [1 3 'a]
== false
JaimeVargas
21-Sep-2005
[404]
Shouldn't?
parse [1][1] ;== true
Geomol
21-Sep-2005
[405x2]
So if you wanna check for exactly one time -1, you write [1 1 -1].
Jaime, when you put a number in, it's the start of a min/max indicator. 
You never type max or what to search for, so it fails.
Graham
21-Sep-2005
[407]
well, apparently numbers are not literals when parsing ...
Geomol
21-Sep-2005
[408]
Same as
>> parse [1] []
== false
Graham
21-Sep-2005
[409]
must add this to the wikibook :)
Geomol
21-Sep-2005
[410x2]
>> parse [-1 -1] [2 -1]
== false
>> parse [-1 -1] [2 2 -1]
== true
The first doesn't give meaning to parse, because a number means a 
min, so parse look for a max, and then the data.
JaimeVargas
21-Sep-2005
[412x3]
A bit consusing. Maybe we should express ranges differently.
Maybe with an issue.
#1-4
Geomol
21-Sep-2005
[415x2]
Then that needs to be parsed too.
>> i: #1-4
== #1-4
>> i/1
== #"1"
>> i/2
== #"-"
>> i/3
== #"4"
But I could have written:
#001-00004

>> parse [1 1 1] [001 00004 1]
== true
I think, Carl likes to keep it short. :-)
JaimeVargas
21-Sep-2005
[417]
What about a pair for ranges.
Geomol
21-Sep-2005
[418]
Yes, that is better.
JaimeVargas
21-Sep-2005
[419]
literals can help sometimes. But then the problem becomes that pair 
literal could have the same problem than number literal has now.
Geomol
21-Sep-2005
[420]
But then this will give problem:
>> parse [1x2] [1x2]
== true
JaimeVargas
21-Sep-2005
[421x3]
Yep.
But parse [1][1] ;== false (seems odd).
Maybe rebol needs a literal representation for ranges.
Geomol
21-Sep-2005
[424]
yes, but if you changed min/max to a pair, then
parse [1x2][1x2]
wourld fail.
JaimeVargas
21-Sep-2005
[425x3]
I understand. I just suggesting that the parse dialect could be further 
optimized.
Or enhanced.
But I guess adding extra syntax still get us in trouble.
Graham
21-Sep-2005
[428x2]
I guess block parsing is by datatypes and not Rebol values.
except for words .. hmm... confusing.
BrianH
22-Sep-2005
[430]
But numbers are literals when parsing. It's just that they're syntax 
too, at least in parse rules.
Ladislav
22-Sep-2005
[431x2]
hi all, this is an "old" issue Graham: it is in REP for quite a long 
time
(together with my suggestion how to solve it)
Graham
22-Sep-2005
[433]
where on REP ?
Ladislav
22-Sep-2005
[434x3]
let me look
One place is this: http://www.compkarori.com/vanilla/display/TO%2C+THRU+And+NOT+PARSE+Rules
, but I think, there was more
then I found this: http://www.rebol.net/list/list-msgs/32392.html
Graham
22-Sep-2005
[437]
LIT, or LITERAL would be good.
Ladislav
22-Sep-2005
[438]
and one more: http://www.fm.vslib.cz/~ladislav/rebol/rep.html
Graham
22-Sep-2005
[439]
how has Carl responded to these parse suggestions?
Ladislav
22-Sep-2005
[440]
he said (a few days ago), that he will arrange for some uninterrupted 
time at the DevCon with me to hear my suggestions, so this is one 
more to remind him
Graham
22-Sep-2005
[441]
Good.
Pekr
22-Sep-2005
[442x2]
good :-)
Ladislav - buy Carl some good whisky first ... better chance to succeed 
:-)
Ladislav
22-Sep-2005
[444]
does he like whisky? I thought he loved REBOL wine?
Pekr
22-Sep-2005
[445]
hmm, I would have to find some old discussion with Carl, he likes 
whisky but he also suggested some othe drink to me :-)
Graham
22-Sep-2005
[446]
Buy him some lousy wine so he will feel good that Sassenranch wine 
is so much better :)
Pekr
22-Sep-2005
[447]
:-) No problem with some bad czech wine :-)
Rebolek
22-Sep-2005
[448]
buy him some 'burcak', he probably doesn't know, what it is ;)
Ladislav
22-Sep-2005
[449]
I think he doesn't even know it is a drink