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

World: r3wp

[Parse] Discussion of PARSE dialect

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
Graham
22-Sep-2005
[450]
buy some copies of the sdk .. he won't worry about the wine then!
Geomol
22-Sep-2005
[451]
It will probably be hard to find bad wine, where the DevCon is in 
northern Italy. :-) And you're probably not allowed to bring bad 
wine into that area. ;-)
Graham
8-Oct-2005
[452x2]
Any parse experts here today?
no matter...
Brock
9-Oct-2005
[454]
Not an expert, but if you ask, you never know!!!
Graham
10-Oct-2005
[455x3]
I want to split a text string at n characters but not in the middle 
of a word ie. split at the next space.
split-text: func [ txt n 
	/local frag result bl
][
    bl: copy []
    result: copy ""

    frag-rule: compose/deep [ copy frag (n) skip (print frag append result 
    frag) copy frag to #" " (if not none? frag [ print frag append result 
    frag ]
append bl copy result clear result) ]
    parse/all txt [ some frag-rule ]
    bl
]
works outside the function, but not inside :(
Ladislav
11-Oct-2005
[458]
compose/deep [ copy frag (n) skip (print frag append result frag) 
copy frag to #" " (if not none? frag [ print frag append result frag 
]
append bl copy result clear result) ]


looks suspicious to me - don't forget that your parens are there 
for two different purposes. My guess is, that you don't need compose?
Graham
11-Oct-2005
[459x2]
I think I tried it without the compose ...
I'll give it another go.
Ladislav
11-Oct-2005
[461]
copy frag n skip should be perfectly OK
Graham
11-Oct-2005
[462]
hmm.  that works.  except I miss the last piece of the text as if 
last piece less than n, it doesn't get copied.
Ladislav
11-Oct-2005
[463]
example of what you get and what want?
Graham
11-Oct-2005
[464x2]
split-text "this is a sentence" 11
[]
I want [ "this is a sentence" ]
Ladislav
11-Oct-2005
[466]
how about:

    copy frag [to #" " | to end]
Graham
11-Oct-2005
[467x2]
yah! that works.
I tried putting in an alternate rule of " | copy frag to end " but 
that hung the parser.
Ladislav
11-Oct-2005
[469]
this should work too:

    [copy frag #" " | copy frag to end]