kyle smith
unread,Aug 20, 2008, 12:02:25 AM8/20/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Clojure
I think it would be nice to allow functions inside regexs. Lets
define \fn to escape a function name. This would allow us to define
recursive regexs*, for example parenthesis matching.
(defn match-parens [x]
(match "\(([^()]+|\fnmatch-parens)*\)" x))
The function arguments could be the last matched group, some user-
defined group, or just the current position in the string/sequence. A
match would be indicated by any non-nil return value, which you could
capture by enclosing the function call in a group. You could also
match on recursion depth (by storing it in a variable and incrementing
it in the function).
I have a few applications for this. First, I'm making a dsl that
involves set operations (intersect, union, etc). I would like to do
syntax checking for user-defined scripts. (They would have a very
hard time decyphering stack traces.) I would also like to check the
logfile of a program to see if the floating point numbers it generates
are reasonable.
In general, this might be useful for writing parsers, validating html/
xml, etc. This seems like a powerful idea, so I'm sure it would be
nice for all sorts of things. What are everyone's thoughts?
*Yes, I know that's not proper terminology.