On Thursday 03 January 2002 12:13 pm, Ian Bicking wrote:
> The only annoying part is that the translation x.setY(z) to x.y = z
> is hard to do in an editor. �It can't be done just with regexes,
> though, as it has to understand nested expressions.
Why would it have to understand nested expressions? Aren't setFoo()
methods always invoked as statements?
foo.setBar(blahblah)
Something like:
$\t+[A-Za-z0-9_]+\.set[A-Z][A-Za-z0-9_]*\(\.+\)^
I always get my regexes slightly wrong the first time, but the gist is:
beginning of line
one or more tabs
identifier
".set"
cap letter
more alphanumerics
"("
1 or more characters
")"
end of line
I think regexes could handle that. If they couldn't, we could certainly
deal with the situation with our own code.
Then axe the "set", decap the identifier, replace "(" with " = " and
kill the rightmost ")".
foo.setBar(baz)
foo.bar = baz
Or am I missing something?
Actually, if you did that blindly you would screw up the occasional
setFooBar() that takes multiple arguments, assuming these exist in
Webware.
BTW Another thought is that Python comes with a module to translate
source to AST nodes that can then be examined. If I remember right.
But in general I agree with Tavis' comment that this could be done line
by line.
Also, I'm in favor and an "all the way" approach. e.g., a script that
would translate 99% of code and mark problem spots with a tag that
could be grepped for (assuming we didn't achieve 100%).
-Chuck
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss