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

--- [EMAIL PROTECTED] wrote:
> 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)                             ; <=== here
>         [
>             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
> 
> }
> 
> > 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.
> >
> >
> > ----- Original Message -----
> > From: <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Monday, July 31, 2000 4:06 AM
> > Subject: [REBOL] Parse does not have "not" match type. Re:
> >
> >
> > > 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
> > > ]
> > >
> > >
> >
> >
> >
> 


__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/

Reply via email to