perl 高手请进,如何从一个java元文件中把其中的method和其实现提取出来
例如,
import java.uil.*;
import java.javax.*;
class test{
private int a;
private int b = 10;
public abstruct void getMethod(String name, String Type);
public Test(int a, int b)
{...}
public int getValue() {
....
}
}
提取出一个hash表name<->method:
Test-> public Test(int a, int b)
{...}
getValue -> public int getValue() {
....
}
其中不应当包含abstruct 方法和字段。
以下表达式能提取出来嵌套的{}结构
our $openParens = 0;
my $NestedGuts = qr{
(?{ local $OpenParens = 0 }) # Counts the number of nested opens waiting to close.
(?> # atomic-grouping for efficiency
(?:
# Stuff not parenthesis
[^{}]+
# An opening parenthesis
| \{ (?{ $OpenParens++ })
# Allow a closing parenthesis, if we're expecting any
| \} (?(?{ $OpenParens != 0 }) (?{ $OpenParens-- }) | (?!) )
)*
)
(?(?{ $OpenParens != 0 })(?!)) # If there are any open parens left, don't finish
}x;
$str =~/({NestedGuts })/g
问题就是如何构造这个hash表???