Hi Andrew,

nice work. (I was planning to get started on something like that myself.
Haven't had time yet.)

One little bug I found (adding ?! to the first sample regex string):
a) "noty" causes an error in

>  "?!" (append RegExp_Parser [noty]) |

here:
"intruder"
[noty "ted" | "admin" | "bobr" | "andrew" | "elan" | "keith" | "cheryl" |
"joel" | "brady" end]
** Script Error: noty has no value.
** Where: parse/all probe Exp probe RegExp_Parse

Probably you meant "not". I don't think that the REBOL parse dialect
supports the word "not". 

2. Doesn't * mean zero or more? you appear to replace it by | none.
>  "*" (append RegExp_Parser [| none]) |

That would not account for repetitive patterns. It should be replace by
something like 
any xxx
where xxx would be whatever it is that may appear zero or more times.

Come to think of it, I think regexs are a little more complicated then this
and cannot be implemented by a one-to-one mapping of regex symbols to REBOL
parse words. 

Let me think about it a little longer, but IMHO you will need some kind of
state machine to do it correctly.

Hope this helps.


At 05:26 PM 1/20/00 -0800, you wrote:
>Here's what I've got so far:
>
>RegExp_Parse: function [RegExp [string!]] [
> RegExp_Rules RegExp_Parser Match Match_Character Match_Characters
> ][
> RegExp_Parser: make block! 4 * length? RegExp
> Match: make string! 0
> Match_Character: charset [#"0" - #"9" #"A" - #"Z" #"a" - #"z"]
> Match_Characters: [some Match_Character]
> append RegExp_Parser [to]
> RegExp_Rules: [
>  "^^" (if 'to = first RegExp_Parser [remove head RegExp_Parser]) |
>  "*" (append RegExp_Parser [| none]) |
>  "?!" (append RegExp_Parser [noty]) |
>  "|" (append RegExp_Parser [|]) |
>  "$" (append RegExp_Parser [end]) |
>  "(" |
>  ")" |
>  copy Match Match_Characters (append RegExp_Parser Match)
>  ]
> parse/all RegExp [some RegExp_Rules]
> RegExp_Parser
> ]
>
>RegExp: func [RegExp [string!] Exp [string!]] [
> parse/all probe Exp probe RegExp_Parse RegExp
> ]
>
>print RegExp "^^(ted|admin|bobr|andrew|elan|keith|cheryl|joel|brady)$"
>"intruder"
>print RegExp "^^(ted|admin|bobr|andrew|elan|keith|cheryl|joel|brady)$"
>"cheryl"
>
>And here it is running:
>
>>> do %bobr.r
>Script: "bobr" (20-Jan-1999)
>"intruder"
>["ted" | "admin" | "bobr" | "andrew" | "elan" | "keith" | "cheryl" | "joel"
>| "brady" end]
>false
>"cheryl"
>["ted" | "admin" | "bobr" | "andrew" | "elan" | "keith" | "cheryl" | "joel"
>| "brady" end]
>true
>
>Parenthesis don't work, yet. Gabrielle, Elan? Feel free to improve it.
>
>I've also noticed that _two_ calls to parse in the one function doesn't seem
>to work right.
>
>Andrew Martin
>ICQ: 26227169
>[EMAIL PROTECTED]
>http://members.xoom.com/AndrewMartin/
>-><-
>
>
>
>

;- Elan >> [: - )]

Reply via email to