Ryan Pavlik
10/8/2003 10:23:00 PM
On Thu, 9 Oct 2003 07:10:42 +0900
Simon Strandgaard <qj5nd7l02@sneakemail.com> wrote:
<snip>
> I want to use same syntax as Ruby's regex, and perhaps extend it
> with some editor stuff, perhaps like:
There seem to be simpler/more elegant solutions to these problems than
reimplementing pcre:
> * how to traverse the datastructure, jump over folds, jump into
> folds.
> * regex on columnar selections.
> * mechanism for getting the syntax-state: perhaps a regex which
> only operates inside comments, apply regex to variable-names, etc.
All three of these can easily be accomplished by providing constrained
input to the matcher. For folds etc, first you grab the pieces you
want (folds, no folds), then apply the re. For colums, same deal.
Extract the column, then apply. I'm sure you can guess where this is
going for the last one... extract and apply the regexp only to
comments or variable names.
You could have a simple "Region" class which selects the appropriate
areas, make an array of applicable regions, and then apply the regexp
to each. This gives you three exceedingly simple tasks:
1) Region objects defined by <start> and <end>.
2) Regexp application to a region.
3) Matching code to produce Regions. (Obviously, you'll need
this in any case, to select only comments, etc.)
I'd say this is way simpler, more effective, and more extensible than
redefining all-new regexp syntax. Especially since the existing
syntax is hairy enough. ;-)
--
Ryan Pavlik <rpav@mephle.com>
"You'd be surprised what a platoon of heartless ninja lawyers
can do in favor of a position." - 8BT