World: r3wp
[Parse] Discussion of PARSE dialect
older newer | first last |
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 [469x2] | this should work too: [copy frag #" " | copy frag to end] |
rather: [copy frag to #" " | copy frag to end] | |
Graham 11-Oct-2005 [471] | Hmm. It's failing when the text is less than n. |
Ladislav 11-Oct-2005 [472] | strange |
Graham 11-Oct-2005 [473x2] | [ copy frag n | copy frag to end ] |
at the beginning I guess | |
Ladislav 11-Oct-2005 [475] | aha, this one, yes, right |
Graham 11-Oct-2005 [476] | [ copy frag n skip | copy frag to end ] |
Ladislav 11-Oct-2005 [477] | or copy frag [n skip | to end] |
Graham 11-Oct-2005 [478] | nope. |
Ladislav 11-Oct-2005 [479] | if append "" none works as it does, then it is a problem with the none value |
Tomc 11-Oct-2005 [480x2] | split-text: func [txt [string!] n [integer!] /local frag fraglet bl frag-rule bs ws ][ ws: charset [#" " #"^-" #"^/"] bs: complement ws bl: copy [] frag-rule: [ any ws copy frag [n skip] (print frag) opt[copy fraglet some bs (print fraglet)] (insert tail bl join frag fraglet) ] parse/all txt [some frag-rule] bl ] |
will prolly fail on tezt < n as well | |
Graham 11-Oct-2005 [482x2] | it does fail. |
simpler to just check the size of the string before it gets worked on. | |
Tomc 11-Oct-2005 [484x2] | yep |
but the last line being less than n is the same thing | |
Ladislav 11-Oct-2005 [486] | I must say, that the NONE issue is quite annoying/inconsistent (IMO) |
Graham 11-Oct-2005 [487] | yeah .. it is. |
Ladislav 11-Oct-2005 [488x2] | how about this one?: copy frag [n skip | to end] (frag: any [frag ""]) |
maybe we should put it to RAMBO as an enhancement request? | |
older newer | first last |