Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Parse does not have "not" match type.

 [1/8] from: bhandley:zip:au at: 30-Jul-2000 12:07


I was playing around with the idea of using rebol to convert EBNF to Rebol parse rules. A strange occupation maybe, but I thought it might be useful one day. Anyway, I found a rule in EBNF, as described in XML1.0 - http://www.w3.org/TR/REC-xml.html, for which I believe there is no equivalent in Rebol - and I cannot see how it can be worked around. It is the A - B rule which says "matches any string that matches A but does not match B". I looked into the use of this rule in the xml spec and found that it does not relate simply to characters, so I cannot just do something with complement . Is there a way, or no? Thanks, Brett.

 [2/8] from: lmecir:geocities at: 30-Jul-2000 20:06


Hi, I think, that Parse has got a bug as in:
>> parse "a" [none skip]
== true cc-ing to feedback. Here is a version of A-B-rule, that should work reliably. Test it please. A-B-rule: func [ "Generate an A-B parse rule" A [block!] {A-rule} B [block!] {B-rule} /local o ] [ o: make object! [ A-rule: A B-rule: B res-rule: none ] bind/copy [ (self) [ B-rule (res-rule: [to end skip]) | A-rule (res-rule: []) | (res-rule: [to end skip]) ] res-rule ] in o 'self ]

 [3/8] from: lmecir:geocities at: 30-Jul-2000 10:28


Hi, try this: (but look out!) As long, as Rebol functions are CQSB with DRP, there are problems with Rule-res word local to A-B-rule function. A-B-rule: func [ "Generate an A-B parse rule" A [block!] {A-rule} B [block!] {B-rule} /local succeed fail rule-res ] [ [[B to end (rule-res: [none skip]) | A (rule-res: [])] rule-res] ] Regards Ladislav

 [4/8] from: bhandley:zip:au at: 31-Jul-2000 15:17


That's brilliant Ladislav. It took a little while to understand what magic you put there, and I learnt something as a result. I've made a few tests so far and cannot fault it. Thanks, Brett.

 [5/8] from: lmecir:geocities at: 31-Jul-2000 14:45


Hi, the latest version (see below) is better (the generated rule can be used recursively if needed): A-B-rule: func [ {Generate an A-B parse rule} A [block!] {A-rule} B [block!] {B-rule} /local o ] [ o: make object! [ A-rule: A B-rule: B res-rule: none ] bind/copy [ (self) [ B-rule (res-rule: [to end skip]) | (res-rule: A-rule) ] res-rule ] in o 'self ] { Example: a: [any "a" "b"] b: ["aa"] a-b: a-b-rule a b parse "ab" a-b parse "aab" a-b } not-rule: func [ "Generate a not A parse rule" A [block!] {A-rule} /local o ] [ o: make object! [ A-rule: A res-rule: none ] bind/copy [ (self) [ A-rule (res-rule: [to end skip]) | (res-rule: []) ] res-rule ] in o 'self ] { Example: a: [any "a" "b"] not-a: not-rule a parse "ab" not-a parse "b" not-a parse "" not-a }

 [6/8] from: yaozhang:rocketmail at: 31-Jul-2000 10:16


hi put up the question just in case i missed something+ seems could remove the (self) under bind/copy to achieve this function. or is it required for some reason? -z --- [lmecir--geocities--com] wrote:

 [7/8] from: lmecir:geocities at: 31-Jul-2000 23:03


Hi Zhang, the problem is the GC bug. If the bug didn't exist, (self) is unnecessary. As long, as the GC bug exists, (self) prevents the GC from collecting O. (for more information you can read Words, Bindings and Contexts thread) Regards Ladislav

 [8/8] from: yaozhang:rocketmail at: 1-Aug-2000 9:14


Thanks, Ladislav so my reading - Object has local context local context could be GC'd if not referenced (self) below provide the reference Thanks, -z --- [lmecir--geocities--com] wrote: