In order to improve my skills with the REBOL parse word, I thought I would go
through "Mastering Regular Expressions" by Jeffrey Freidl and do all the
examples in REBOL. Here is my first attempt and it does not work.
The script is supposed to take a list of files and indicate whether the word
"setsize" occurs equally, more, or less than the number of times that the word
"resetsize" occurs.
REBOL [
Title: "Balance setsize and resetsize"
]
;; q1 in my head: how do I do word boundaries?
rules: [
to "resetsize" (size-cmds: size-cmds - 1)
|
to "setsize" (size-cmds: size-cmds + 1)
]
proc: func [ filenames [block!] ] [
foreach file filenames [
size-cmds: 0
parse read to-file file rules
prin reform [ "in" file ": " ]
either size-cmds = 0 [
print "resetsize cmds matched # of setsize cmds"
][ either size-cmds > 0 [
print "resetsize cmds > # of setsize cmds"
][ print "resetsize cmds < # of setsize cmds" ]
]
]
]
terrence-brannon: [[EMAIL PROTECTED] perl-refugee myth-gamer]
free-email: http://www.MailAndNews.com
free-usenet: http://www.mailAndNews.com
; all the above is real REBOL code, believe it or not.