问题
In a Javalike language where parsers and other advanced methods do not exist I want to parse and evaluate source files. It's the language Apex from the proprietary cloud platform Salesforce.com. I know its based on Antrl/Java but there is no way to parse it from inside the platform as I want to parse Apex code with Apex code and the only means is Regexp.
When reading in a source file I want (by using a regexp) to match and extract all parts that are interesting to draw an UML class diagram:
- class declaration
- method declaration
- inner class declaration
I want to find them and by using Regexp groups I would love to be able to directly access parts of the matched string. Those parts are:
- Is is public or private?
- Is it static, abstract or default?
- Is it a class or an interface?
- What's the methodname?
- What's the Returntype?
- What's the param list?
来源:https://stackoverflow.com/questions/14870742/regexp-to-match-members-declaration-of-java-source-files