Created
February 8, 2012 17:10
-
-
Save wader/1771131 to your computer and use it in GitHub Desktop.
Print class and instance methods declarations from Objective-C implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env awk -f | |
# print class and instance methods declarations from implementation | |
# Usage: ./printmethods.awk class.m or awk -f printmethods.awk class.m | |
/^[[:space:]]*@implementation/ { | |
implementation = 1; | |
} | |
/^[[:space:]]*@end/ { | |
implementation = 0; | |
} | |
/^[[:space:]]*[\-\+]/ { | |
if(implementation) { | |
method = 1; | |
collect = ""; | |
} | |
} | |
/[^[:space:]]/ { | |
if(implementation && method) { | |
p = index($0, "{"); | |
if(p == 0) { | |
if(collect == "") | |
collect = $0 | |
else | |
collect = collect $0 "\n"; | |
} else { | |
method = 0; | |
# trim white space and "{" from line end | |
gsub("[\{[:space:]]*$", "", $0); | |
collect = collect $0; | |
# trim white space from start | |
gsub("^[[:space:]]*", "", collect); | |
print collect ";" | |
} | |
} | |
} |
That would be much nicer yes, this was a quick hack for someone on stackoverflow :) Do you have any documentation how to use the AST talkers? seams as the include files for clang is not included with Xcode :( Found this http://llvm.org/devmtg/2010-11/Gregor-libclang.pdf which seams nice but maybe old? C++ and libast may be a better choice?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try embedding clang and use the AST walkers :)