World: r3wp
[Parse] Discussion of PARSE dialect
older newer | first last |
btiffin 27-Jun-2007 [1951] | Yep. I'm out. Not experienced enough to have piped up... ;) |
Steeve 27-Jun-2007 [1952x2] | and what is your mater ? ;-) |
we can talk of rebcode if you want :-) | |
btiffin 27-Jun-2007 [1954] | Thinking about this one, you'd have to repeat all the alternatives. Defeating the purpose...but I'll bet Chris or Geomol or Anton or... will have a workable solution posted before ya know it. |
Steeve 27-Jun-2007 [1955] | i h'ave many alternatives (all comsuming lot of code) that's not the point, i just think it could be more elegant to have such a command |
btiffin 27-Jun-2007 [1956] | Maybe we could hold side bets on which rebol will come up with the solution first...I'd put money down on Oldes or Volker giving you a workable :) |
Steeve 27-Jun-2007 [1957] | if you say so, i tried many alternatives, but they are all uggly |
Brock 27-Jun-2007 [1958] | try this... parse "AB" [some ["A" | "B" | "C"] | none ] |
Steeve 27-Jun-2007 [1959] | i don't want to parse "AB" but any combinations of "ABC" |
btiffin 27-Jun-2007 [1960] | His works. I tried it without the terminating | none and it spun out, so I didn't mention it :) |
Steeve 27-Jun-2007 [1961x2] | parse "AB" sould return false |
not true | |
Brock 27-Jun-2007 [1963x2] | why would AB return false? |
so it must be three characters? | |
Steeve 27-Jun-2007 [1965x2] | because i want parse the complete serie "ABC" in any combination |
yes 3 characters | |
btiffin 27-Jun-2007 [1967] | What it you put 1 repeats inside the some? |
Steeve 27-Jun-2007 [1968] | write it plz |
btiffin 27-Jun-2007 [1969] | nevermind... just tried it. piping up out of turn again :) |
Steeve 27-Jun-2007 [1970x2] | i just don't understand what you mean |
ah ok, it doesn't work :-) | |
Brock 27-Jun-2007 [1972] | do all three characters need to be present? |
btiffin 27-Jun-2007 [1973] | I tried parse "AB" [some [1 "A" | 1 "B" | 1 "C"] | none] ...returns true |
Brock 27-Jun-2007 [1974] | or can characters be duplicated? |
Steeve 27-Jun-2007 [1975] | no Brock |
Brock 27-Jun-2007 [1976] | the | none handles situations where the rule doesn't apply, so almost everything will return true |
btiffin 27-Jun-2007 [1977] | Brock; Without it it'll endless loop no? |
Steeve 27-Jun-2007 [1978x2] | no |
just never use an ''opt" rule in a some or any block | |
Brock 27-Jun-2007 [1980] | will it just be instances of A B & C? |
Steeve 27-Jun-2007 [1981x6] | one instance of each in any order (but just one instance) |
the awaiting result is a: b: c: false parse "CAB" [some ["A" (a: true) | "B" (b: true) | "C" (c: true)]] if all [a b c ] [print "ok"] | |
*expecting result | |
except that this code is wrong for series with repeting characters like "AABCC" | |
(should increment a b and c instead using boolean) | |
anyway , that's not the point , i know how to do that, but i just think it's ugly | |
btiffin 27-Jun-2007 [1987x2] | parse "ABC" [3 [1 "A" | 1 "B" | 1 "C"]] ? |
nevermind... :) AAA returns true | |
Steeve 27-Jun-2007 [1989x2] | yep |
i really think it's not feasible without using counters | |
Brock 27-Jun-2007 [1991x3] | I think I have it define a rule; rule: [1 ["A" | "B" | "C"]] then parse parse "cAB" [[rule] [rule] [rule]] |
the one indicates that there must be an occurence of one of the three characters... supplying the rule then requires three characters to be entered. | |
... but it allows multiple characters... damn | |
Steeve 27-Jun-2007 [1994] | and it works too with the serie "AAA" |
Brock 27-Jun-2007 [1995] | which is bad |
Steeve 27-Jun-2007 [1996] | yrp |
btiffin 27-Jun-2007 [1997] | parse can change the string as it goes right? What if you tried marking them off with X's as you found them? |
Brock 27-Jun-2007 [1998] | I was thinking the same thing, removing each character from a block as each rule is processed. |
Steeve 27-Jun-2007 [1999] | yeah it's possible but it's like hanging counters, you need to have some code to check the result and allowing the parser to continue further |
Brock 27-Jun-2007 [2000] | so your ideal solution would not use anyting other than parse? |
older newer | first last |