lexing nested parenthesis

Dave Cinege dcinege at psychosis.com
Sun Jul 28 23:57:21 EDT 2002


It's nice when you open up your reference book, and immediately
find a section on what you want to do. 

It sucks large donkey rocks when that section is titled:
"Difficulties and Impossiblies" (Mastering Regular Expressions)

I've been playing with shlex, and think in my application I'm
better off minimizing or avoiding it. 

Primarily I want to do search, evaluate, modify, and replace
on a line by line basis. The diffculty comes with matching
arbitrary nested constructs, IE nested parenthesis.

IE
	if 1 and (var1 or ?(-d /etc/)):

I want to find ?(.*), but not runneth under or over.
Evaluating a token at a time will become disgusting. It also
seems redundant as you can see it's the same parsing rules as
Python has. (And in fact that is what the line will be
converted to.)

Can anyone recommend a 'Better Way'? I'm thinking maybe subclassing
generate_tokens.

Dave

-- 
The time is now 22:48 (Totalitarian)  -  http://www.ccops.org/






More information about the Python-list mailing list