World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
PeterWood 14-May-2009 [2249x3] | That's a good idea but I was being lazy partly because it's such a pain to copy and paste in AltME (it strips out all line endings). |
Here's the big rule now fixed : >> parse/all inp [ any [copy range [[digit opt digit "/"] [some digit opt ["-" some digit]]] (print range) | skip ]] 2/2 2/4-6 2/33-37 == true | |
Ladislav, that's my understanding | |
Steeve 14-May-2009 [2252] | rewrote Peter's with named sub-rules prefix: [digit opt digit] sufix: [some digit opt ["-" some digit]] target: [prefix #"/" sufix] parse/all inp [any [copy range target (print range) | skip]] |
PeterWood 14-May-2009 [2253] | Thanks, Steeve |
mhinson 14-May-2009 [2254] | sorry the phone rang |
PeterWood 14-May-2009 [2255] | So now we can capture all the ranges: >> all-ranges: copy [] == [] >> parse/all inp [any [copy range target (insert tail all-ranges range) | skip]] == true >> all-ranges == ["2/2" "2/4-6" "2/33-37"] |
Steeve 14-May-2009 [2256] | prefix can be: prefix: [1 2 digit] |
PeterWood 14-May-2009 [2257] | Once we've captured all-ranges, we can process them in a second step : |
mhinson 14-May-2009 [2258] | Ladislav, I am not sure I understand your terminology. record: [random-part whitespace repeated-part any ["," repeated-part]] random-part may be absent repeated-part is a number between 1 & 13 followed by "/" any is the bit we want and will be a number or a range , is not present at the end of the line repeated-part is the same as above, but will not be the last thing on the line. |
PeterWood 14-May-2009 [2259] | I need to go now but your in good hands. |
Ladislav 14-May-2009 [2260x3] | mhinson: OK, let's proceed further |
so you are saying, that random-part may be a-word a-number or absent. This is it: random-part: [a-word | a-number | none] | |
is this understood? | |
mhinson 14-May-2009 [2263x2] | Thanks for your help Peter. I am taking notes & understanding it I think. |
Yes, that sounds a good description of the random part. | |
Ladislav 14-May-2009 [2265x2] | fine, we need to describe further, what is a-word: a-word: [some alpha] , is this adequate? |
alpha: charset [#"a" - #"z" #"A" - #"Z"] | |
mhinson 14-May-2009 [2267] | yes |
Ladislav 14-May-2009 [2268] | fine, now for the a-number part. how big a number can it be? |
mhinson 14-May-2009 [2269] | 1 to 2000 will cover it |
Ladislav 14-May-2009 [2270] | a-number: [one-to-two 3 digit | non-zero-digit 0 2 digit] |
Steeve 14-May-2009 [2271] | hum.. a-number: [1 4 digit] is that not enough ? |
Ladislav 14-May-2009 [2272x2] | that allows for 0 |
as well as for 9999 | |
mhinson 14-May-2009 [2274] | that would be fine |
Ladislav 14-May-2009 [2275] | ok then, you pick what is appropriate |
Steeve 14-May-2009 [2276x2] | yep but it's an average limit that mhinson gave |
no need to be strict here, i think | |
Ladislav 14-May-2009 [2278x3] | repeated-part will not be the last thing on the line : fine, what will be the last thing on the line? |
(except for the newline character, of course) | |
will the newline character be actually there? | |
mhinson 14-May-2009 [2281] | the final wanted bit of data will be the last thing, then the end of the line because the data has been read from the file with read/lines |
Ladislav 14-May-2009 [2282x4] | how do you call the last part of the data, isn't it the same part that may repeat more than once? |
(divided by comma, of course) | |
one more thing we need to make agreement on: do we want to rely on the default whitespace handling or be more specific and say exactly where whitespace may be? | |
well, it looks, that I will have to run soon | |
Maxim 14-May-2009 [2286] | mhinson... If I can encourage you... once you will "get" it... it will all become <really> simple. you mind is just adapting to maping rules and seeing the inherent stack of what they imply. Don't give up, it will all become clear. I think we all feel the same anxiety at first. Most don't follow through, its a good thing that you persevere. :-) |
mhinson 14-May-2009 [2287] | the white space is not present in the intresting part of the data so would that suggest the default handleing would be ok? |
Maxim 14-May-2009 [2288] | you mean not using /all? |
Ladislav 14-May-2009 [2289] | probably yes |
mhinson 14-May-2009 [2290] | yes |
Ladislav 14-May-2009 [2291x2] | the rule line: [random-part repeated-part any ["," repeated-part]] just means, that at the start there is a special random-part, and then we have more repeated-part's separated by comma |
notice, that the comma isn't at the end! | |
mhinson 14-May-2009 [2293] | I dont understand why we need the repeated-part in twice? |
Ladislav 14-May-2009 [2294x2] | we didn't specify what exactly is in the repeated-part, so we can continue: repeated-part: [one-to-thirteen "/" a-range] |
repeated-part twice: good question. we stated it so, to describe the situation, when the quantity of repeated-part's is one less than the quantity of commas | |
Maxim 14-May-2009 [2296] | because of the comma (",") |
Ladislav 14-May-2009 [2297] | sorry, "one more" |
Maxim 14-May-2009 [2298] | there is no comma before the first repeated-part, basically. |
older newer | first last |