I need to analyze Objective-C static code, mainly AST, after looking into the possible tools I found out that Clang tool from LLVM can dump the AST, so I used the terminal to test it using this command:
clang -cc1 -ast-dump ~/SomeTest.m
but I'm getting this error:
In file included from /Users/myusername/SomeTest.m:9:
/Users/myusername/SomeTest.h:9:9: fatal error: 'UIKit/UIKit.h' file not found
#import <UIKit/UIKit.h>
^
typedef __int128_t __int128_t;
typedef __uint128_t __uint128_t;
typedef SEL *SEL;
typedef id id;
typedef Class *Class;
struct __va_list_tag {
unsigned int gp_offset;
unsigned int fp_offset;
void *overflow_arg_area;
void *reg_save_area;
};
typedef struct __va_list_tag __va_list_tag;
typedef __va_list_tag __builtin_va_list[1];
@interface just4testViewController@end
@implementation just4testViewController
- (void) dealloc (CompoundStmt 0x7f86b183b110 </Users/myusername/SomeTest.m:14:1, line:16:1>)
- (void) didReceiveMemoryWarning (CompoundStmt 0x7f86b183b2a0 </Users/myusername/SomeTest.m:19:1, line:24:1>)
- (void) viewDidUnload (CompoundStmt 0x7f86b183b430 </Users/myusername/SomeTest.m:37:1, line:41:1>)
- (id) shouldAutorotateToInterfaceOrientation:(id)interfaceOrientation (CompoundStmt 0x7f86b183b648 </Users/myusername/SomeTest.m:44:1, line:47:1>)
@end
1 error generated.
Any idea why I'm getting this? I don't mind using any tool to extract AST from Objective-C code as long as it is reliable and provide documentation for the output
The compiler does not find the UIKit framework. You have to tell it to use it:
clang -framework UIKit -cc1 -ast-dump ~/SomeTest.m
OP says I don't mind using any tool to extract AST from Objective-C code ...
Our DMS Software Reengingineering Toolkit can do this for Objective-C.
For this command line to the DMS-generated parser "domainparser":
run \DMS\Domains\C\ObjectiveCv2\Tools\Parser\domainparser ++AST "C:\temp\test.m"
this Objective C file "test.m":
@implementation GTLClientLoginAuthorizationArgs
@synthesize request = request_,
delegate = delegate_,
selector = sel_,
completionHandler = completionHandler_,
thread = thread_,
error = error_;
+ (GTLClientLoginAuthorizationArgs *)argsWithRequest:(NSMutableURLRequest *)req
delegate:(id)delegate
selector:(SEL)sel
completionHandler:(id)completionHandler
thread:(NSThread *)thread {
GTLClientLoginAuthorizationArgs *obj;
obj = [[[GTLClientLoginAuthorizationArgs alloc] init] autorelease];
obj.request = req;
obj.delegate = delegate;
obj.selector = sel;
obj.completionHandler = completionHandler;
obj.thread = thread;
return obj;
}
- (void)dealloc {
self.request = nil;
self.delegate = nil;
self.selector = NULL;
self.completionHandler = nil;
self.thread = nil;
self.error = nil;
[super dealloc];
}
@end
produces this output with an AST:
Domain Parser for C~ObjectiveCv2 2.4.4
Copyright (C) Semantic Designs 1996-2012; All Rights Reserved
(translation_unit@C~ObjectiveCv2=2#422f080^0 Line 1 Column 1 File C:/temp/test.m
(class_implementation@C~ObjectiveCv2=1048#422f140 Line 1 Column 1 File C:/temp/test.m
(IDENTIFIER@C~ObjectiveCv2=1270#4228b40[`GTLClientLoginAuthorizationArgs'] Line 1 Column 17 File C:/temp/test.m)IDENTIFIER
(super_class_option@C~ObjectiveCv2=1046#4228b80 Line 3 Column 1 File C:/temp/test.m)super_class_option
(instance_variables@C~ObjectiveCv2=1061#4228bc0 Line 3 Column 1 File C:/temp/test.m)instance_variables
(implementation_definition_list@C~ObjectiveCv2=1079#422f0a0 Line 3 Column 1 File C:/temp/test.m
(implementation_definition_list@C~ObjectiveCv2=1079#422e8c0 Line 3 Column 1 File C:/temp/test.m
|(implementation_definition_list@C~ObjectiveCv2=1079#42290a0 Line 3 Column 1 File C:/temp/test.m
| (implementation_definition_list@C~ObjectiveCv2=1078#4228c00 Line 3 Column 1 File C:/temp/test.m)implementation_definition_list
| (property_implementation@C~ObjectiveCv2=1131#4229080 Line 3 Column 1 File C:/temp/test.m
| (property_synthesize_list@C~ObjectiveCv2=1134#4229060 Line 3 Column 13 File C:/temp/test.m
| (property_synthesize_list@C~ObjectiveCv2=1134#4228fc0 Line 3 Column 13 File C:/temp/test.m
| |(property_synthesize_list@C~ObjectiveCv2=1134#4228f40 Line 3 Column 13 File C:/temp/test.m
| | (property_synthesize_list@C~ObjectiveCv2=1134#4228e80 Line 3 Column 13 File C:/temp/test.m
| | (property_synthesize_list@C~ObjectiveCv2=1134#4228de0 Line 3 Column 13 File C:/temp/test.m
| | (property_synthesize_list@C~ObjectiveCv2=1133#4228d00 Line 3 Column 13 File C:/temp/test.m
| | |(property_synthesize_item@C~ObjectiveCv2=1136#4228cc0 Line 3 Column 13 File C:/temp/test.m
| | | (IDENTIFIER@C~ObjectiveCv2=1270#4228c40[`request'] Line 3 Column 13 File C:/temp/test.m)IDENTIFIER
| | | (IDENTIFIER@C~ObjectiveCv2=1270#4228c80[`request_'] Line 3 Column 23 File C:/temp/test.m)IDENTIFIER
| | |)property_synthesize_item
| | )property_synthesize_list
| | (property_synthesize_item@C~ObjectiveCv2=1136#4228dc0 Line 4 Column 13 File C:/temp/test.m
| | |(IDENTIFIER@C~ObjectiveCv2=1270#4228d80[`delegate'] Line 4 Column 13 File C:/temp/test.m)IDENTIFIER
| | |(IDENTIFIER@C~ObjectiveCv2=1270#4228da0[`delegate_'] Line 4 Column 24 File C:/temp/test.m)IDENTIFIER
| | )property_synthesize_item
| | )property_synthesize_list
| | (property_synthesize_item@C~ObjectiveCv2=1136#4228e60 Line 5 Column 13 File C:/temp/test.m
| | (IDENTIFIER@C~ObjectiveCv2=1270#4228e20[`selector'] Line 5 Column 13 File C:/temp/test.m)IDENTIFIER
| | (IDENTIFIER@C~ObjectiveCv2=1270#4228e40[`sel_'] Line 5 Column 24 File C:/temp/test.m)IDENTIFIER
| | )property_synthesize_item
| | )property_synthesize_list
| | (property_synthesize_item@C~ObjectiveCv2=1136#4228f20 Line 6 Column 13 File C:/temp/test.m
| | (IDENTIFIER@C~ObjectiveCv2=1270#4228ea0[`completionHandler'] Line 6 Column 13 File C:/temp/test.m)IDENTIFIER
| | (IDENTIFIER@C~ObjectiveCv2=1270#4228f00[`completionHandler_'] Line 6 Column 33 File C:/temp/test.m)IDENTIFIER
| | )property_synthesize_item
| |)property_synthesize_list
| |(property_synthesize_item@C~ObjectiveCv2=1136#4228fa0 Line 7 Column 13 File C:/temp/test.m
| | (IDENTIFIER@C~ObjectiveCv2=1270#4228f60[`thread'] Line 7 Column 13 File C:/temp/test.m)IDENTIFIER
| | (IDENTIFIER@C~ObjectiveCv2=1270#4228f80[`thread_'] Line 7 Column 22 File C:/temp/test.m)IDENTIFIER
| |)property_synthesize_item
| )property_synthesize_list
| (property_synthesize_item@C~ObjectiveCv2=1136#4229040 Line 8 Column 13 File C:/temp/test.m
| |(IDENTIFIER@C~ObjectiveCv2=1270#4228fe0[`error'] Line 8 Column 13 File C:/temp/test.m)IDENTIFIER
| |(IDENTIFIER@C~ObjectiveCv2=1270#4229020[`error_'] Line 8 Column 21 File C:/temp/test.m)IDENTIFIER
| )property_synthesize_item
| )property_synthesize_list
| )property_implementation
|)implementation_definition_list
|(class_method_definition@C~ObjectiveCv2=1087#422ea00 Line 10 Column 1 File C:/temp/test.m
| (method_type@C~ObjectiveCv2=1103#4229200 Line 10 Column 3 File C:/temp/test.m
| (type_id@C~ObjectiveCv2=647#42291c0 Line 10 Column 4 File C:/temp/test.m
| (AMBIGUITY<type_specifier=388>@C~ObjectiveCv2=1390#4228ca0{2} Line 10 Column 4 File C:/temp/test.m
| |(type_specifier@C~ObjectiveCv2=1144#4229100 Line 10 Column 4 File C:/temp/test.m
| | (IDENTIFIER@C~ObjectiveCv2=1270#42290c0^2#4228ca0:2#4229100:1[`GTLClientLoginAuthorizationArgs'] Line 10 Column 4 File C:/temp/test.m)IDENTIFIER
| | (protocol_option@C~ObjectiveCv2=1057#42290e0 Line 10 Column 36 File C:/temp/test.m)protocol_option
| |)type_specifier
| |(IDENTIFIER@C~ObjectiveCv2=1270#42290c0^2#4228ca0:2#4229100:1... [ALREADY PRINTED] ...)
| )AMBIGUITY
| (ptr_operator@C~ObjectiveCv2=640#4229120 Line 10 Column 36 File C:/temp/test.m)ptr_operator
| )type_id
| )method_type
| (keyword_selector@C~ObjectiveCv2=1095#4229940 Line 10 Column 38 File C:/temp/test.m
| (keyword_selector@C~ObjectiveCv2=1095#4229720 Line 10 Column 38 File C:/temp/test.m
| (keyword_selector@C~ObjectiveCv2=1095#42296a0 Line 10 Column 38 File C:/temp/test.m
| |(keyword_selector@C~ObjectiveCv2=1095#4229580 Line 10 Column 38 File C:/temp/test.m
| | (keyword_selector@C~ObjectiveCv2=1094#42294a0 Line 10 Column 38 File C:/temp/test.m
| | (keyword_declarator@C~ObjectiveCv2=1099#4229480 Line 10 Column 38 File C:/temp/test.m
| | (IDENTIFIER@C~ObjectiveCv2=1270#42291e0[`argsWithRequest'] Line 10 Column 38 File C:/temp/test.m)IDENTIFIER
| | (method_type@C~ObjectiveCv2=1103#4229440 Line 10 Column 54 File C:/temp/test.m
| | |(type_id@C~ObjectiveCv2=647#42293c0 Line 10 Column 55 File C:/temp/test.m
| | | (AMBIGUITY<type_specifier=388>@C~ObjectiveCv2=1390#4229300{2} Line 10 Column 55 File C:/temp/test.m
| | | (type_specifier@C~ObjectiveCv2=1144#42292a0 Line 10 Column 55 File C:/temp/test.m
| | | (IDENTIFIER@C~ObjectiveCv2=1270#4229220^2#4229300:2#42292a0:1[`NSMutableURLRequest'] Line 10 Column 55 File C:/temp/test.m)IDENTIFIER
| | | (protocol_option@C~ObjectiveCv2=1057#4229260 Line 10 Column 75 File C:/temp/test.m)protocol_option
| | | )type_specifier
| | | (IDENTIFIER@C~ObjectiveCv2=1270#4229220^2#4229300:2#42292a0:1... [ALREADY PRINTED] ...)
| | | )AMBIGUITY
| | | (ptr_operator@C~ObjectiveCv2=640#42293a0 Line 10 Column 75 File C:/temp/test.m)ptr_operator
| | |)type_id
| | )method_type
| | (IDENTIFIER@C~ObjectiveCv2=1270#42293e0[`req'] Line 10 Column 77 File C:/temp/test.m)IDENTIFIER
| | )keyword_declarator
| | )keyword_selector
| | (keyword_declarator@C~ObjectiveCv2=1099#4229600 Line 11 Column 45 File C:/temp/test.m
| | (IDENTIFIER@C~ObjectiveCv2=1270#4229460[`delegate'] Line 11 Column 45 File C:/temp/test.m)IDENTIFIER
| | (method_type@C~ObjectiveCv2=1103#4228d40 Line 11 Column 54 File C:/temp/test.m
| | (type_specifier@C~ObjectiveCv2=1143#42294e0 Line 11 Column 55 File C:/temp/test.m
| | |(protocol_option@C~ObjectiveCv2=1057#4229500 Line 11 Column 57 File C:/temp/test.m)protocol_option
| | )type_specifier
| | )method_type
| | (IDENTIFIER@C~ObjectiveCv2=1270#4228d20[`delegate'] Line 11 Column 58 File C:/temp/test.m)IDENTIFIER
| | )keyword_declarator
| |)keyword_selector
| |(keyword_declarator@C~ObjectiveCv2=1099#4229680 Line 12 Column 45 File C:/temp/test.m
| | (IDENTIFIER@C~ObjectiveCv2=1270#42295a0[`selector'] Line 12 Column 45 File C:/temp/test.m)IDENTIFIER
| | (method_type@C~ObjectiveCv2=1103#4229280 Line 12 Column 54 File C:/temp/test.m
| | (simple_type_specifier@C~ObjectiveCv2=1141#42295c0 Line 12 Column 55 File C:/temp/test.m)simple_type_specifier
| | )method_type
| | (IDENTIFIER@C~ObjectiveCv2=1270#4229560[`sel'] Line 12 Column 59 File C:/temp/test.m)IDENTIFIER
| |)keyword_declarator
| )keyword_selector
| (keyword_declarator@C~ObjectiveCv2=1099#4229700 Line 13 Column 36 File C:/temp/test.m
| |(IDENTIFIER@C~ObjectiveCv2=1270#4229520[`completionHandler'] Line 13 Column 36 File C:/temp/test.m)IDENTIFIER
| |(method_type@C~ObjectiveCv2=1103#42294c0 Line 13 Column 54 File C:/temp/test.m
| | (type_specifier@C~ObjectiveCv2=1143#42296c0 Line 13 Column 55 File C:/temp/test.m
| | (protocol_option@C~ObjectiveCv2=1057#42296e0 Line 13 Column 57 File C:/temp/test.m)protocol_option
| | )type_specifier
| |)method_type
| |(IDENTIFIER@C~ObjectiveCv2=1270#4228c60[`completionHandler'] Line 13 Column 58 File C:/temp/test.m)IDENTIFIER
| )keyword_declarator
| )keyword_selector
| (keyword_declarator@C~ObjectiveCv2=1099#4229920 Line 14 Column 47 File C:/temp/test.m
| (IDENTIFIER@C~ObjectiveCv2=1270#4229760[`thread'] Line 14 Column 47 File C:/temp/test.m)IDENTIFIER
| (method_type@C~ObjectiveCv2=1103#4229900 Line 14 Column 54 File C:/temp/test.m
| |(type_id@C~ObjectiveCv2=647#4229860 Line 14 Column 55 File C:/temp/test.m
| | (AMBIGUITY<type_specifier=388>@C~ObjectiveCv2=1390#4229320{2} Line 14 Column 55 File C:/temp/test.m
| | (type_specifier@C~ObjectiveCv2=1144#42297e0 Line 14 Column 55 File C:/temp/test.m
| | (IDENTIFIER@C~ObjectiveCv2=1270#42297c0^2#4229320:2#42297e0:1[`NSThread'] Line 14 Column 55 File C:/temp/test.m)IDENTIFIER
| | (protocol_option@C~ObjectiveCv2=1057#4229740 Line 14 Column 64 File C:/temp/test.m)protocol_option
| | )type_specifier
| | (IDENTIFIER@C~ObjectiveCv2=1270#42297c0^2#4229320:2#42297e0:1... [ALREADY PRINTED] ...)
| | )AMBIGUITY
| | (ptr_operator@C~ObjectiveCv2=640#4229840 Line 14 Column 64 File C:/temp/test.m)ptr_operator
| |)type_id
| )method_type
| (IDENTIFIER@C~ObjectiveCv2=1270#42298c0[`thread'] Line 14 Column 66 File C:/temp/test.m)IDENTIFIER
| )keyword_declarator
| )keyword_selector
| (declaration_star@C~ObjectiveCv2=1085#4229980 Line 14 Column 73 File C:/temp/test.m)declaration_star
| (compound_statement@C~ObjectiveCv2=403#422e920 Line 14 Column 73 File C:/temp/test.m
| (statement_seq@C~ObjectiveCv2=405#422e3e0 {8} Line 15 Column 3 File C:/temp/test.m
| (AMBIGUITY<statement=332>@C~ObjectiveCv2=1390#4229780{2} Line 15 Column 3 File C:/temp/test.m
| |(expression_statement@C~ObjectiveCv2=400#422e200 Line 15 Column 3 File C:/temp/test.m
| | (multiplicative_expression@C~ObjectiveCv2=209#4229e60 Line 15 Column 3 File C:/temp/test.m
| | (IDENTIFIER@C~ObjectiveCv2=1270#42299e0^3#42297a0:1#4229a80:1#4229e60:1[`GTLClientLoginAuthorizationArgs'] Line 15 Column 3 File C:/temp/test.m)IDENTIFIER
| | (IDENTIFIER@C~ObjectiveCv2=1270#4229ca0^2#4229d60:2#4229e60:2[`obj'] Line 15 Column 36 File C:/temp/test.m)IDENTIFIER
| | )multiplicative_expression
| |)expression_statement
| |(simple_declaration@C~ObjectiveCv2=515#422e1e0 Line 15 Column 3 File C:/temp/test.m
| | (AMBIGUITY<type_specifier=388>@C~ObjectiveCv2=1390#42297a0{2} Line 15 Column 3 File C:/temp/test.m
| | (IDENTIFIER@C~ObjectiveCv2=1270#42299e0^3#42297a0:1#4229a80:1#4229e60:1... [ALREADY PRINTED] ...)
| | (type_specifier@C~ObjectiveCv2=1144#4229a80 Line 15 Column 3 File C:/temp/test.m
| | (IDENTIFIER@C~ObjectiveCv2=1270#42299e0^3#42297a0:1#4229a80:1#4229e60:1... [ALREADY PRINTED] ...)
| | (protocol_option@C~ObjectiveCv2=1057#4229a20 Line 15 Column 35 File C:/temp/test.m)protocol_option
| | )type_specifier
| | )AMBIGUITY
| | (declarator@C~ObjectiveCv2=624#4229d60 Line 15 Column 35 File C:/temp/test.m
| | (ptr_operator@C~ObjectiveCv2=640#4229cc0 Line 15 Column 35 File C:/temp/test.m)ptr_operator
| | (IDENTIFIER@C~ObjectiveCv2=1270#4229ca0^2#4229d60:2#4229e60:2... [ALREADY PRINTED] ...)
| | )declarator
| |)simple_declaration
| )AMBIGUITY
| (expression_statement@C~ObjectiveCv2=400#422e3c0 Line 16 Column 3 File C:/temp/test.m
| |(assignment_expression@C~ObjectiveCv2=356#422e360 Line 16 Column 3 File C:/temp/test.m
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e1c0[`obj'] Line 16 Column 3 File C:/temp/test.m)IDENTIFIER
| | (primary_expression@C~ObjectiveCv2=1158#422e340 Line 16 Column 9 File C:/temp/test.m
| | (primary_expression@C~ObjectiveCv2=1158#422e320 Line 16 Column 10 File C:/temp/test.m
| | (primary_expression@C~ObjectiveCv2=1158#422e2e0 Line 16 Column 11 File C:/temp/test.m
| | |(IDENTIFIER@C~ObjectiveCv2=1270#422e220[`GTLClientLoginAuthorizationArgs'] Line 16 Column 12 File C:/temp/test.m)IDENTIFIER
| | |(IDENTIFIER@C~ObjectiveCv2=1270#422e2a0[`alloc'] Line 16 Column 44 File C:/temp/test.m)IDENTIFIER
| | )primary_expression
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e2c0[`init'] Line 16 Column 51 File C:/temp/test.m)IDENTIFIER
| | )primary_expression
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e300[`autorelease'] Line 16 Column 57 File C:/temp/test.m)IDENTIFIER
| | )primary_expression
| |)assignment_expression
| )expression_statement
| (expression_statement@C~ObjectiveCv2=400#422e540 Line 17 Column 3 File C:/temp/test.m
| |(assignment_expression@C~ObjectiveCv2=356#422e500 Line 17 Column 3 File C:/temp/test.m
| | (postfix_expression@C~ObjectiveCv2=130#422e480 Line 17 Column 3 File C:/temp/test.m
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e380[`obj'] Line 17 Column 3 File C:/temp/test.m)IDENTIFIER
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e440[`request'] Line 17 Column 7 File C:/temp/test.m)IDENTIFIER
| | )postfix_expression
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e4a0[`req'] Line 17 Column 17 File C:/temp/test.m)IDENTIFIER
| |)assignment_expression
| )expression_statement
| (expression_statement@C~ObjectiveCv2=400#422e680 Line 18 Column 3 File C:/temp/test.m
| |(assignment_expression@C~ObjectiveCv2=356#422e640 Line 18 Column 3 File C:/temp/test.m
| | (postfix_expression@C~ObjectiveCv2=130#422e600 Line 18 Column 3 File C:/temp/test.m
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e520[`obj'] Line 18 Column 3 File C:/temp/test.m)IDENTIFIER
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e5c0[`delegate'] Line 18 Column 7 File C:/temp/test.m)IDENTIFIER
| | )postfix_expression
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e620[`delegate'] Line 18 Column 18 File C:/temp/test.m)IDENTIFIER
| |)assignment_expression
| )expression_statement
| (expression_statement@C~ObjectiveCv2=400#422e780 Line 19 Column 3 File C:/temp/test.m
| |(assignment_expression@C~ObjectiveCv2=356#422e720 Line 19 Column 3 File C:/temp/test.m
| | (postfix_expression@C~ObjectiveCv2=130#422e740 Line 19 Column 3 File C:/temp/test.m
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e660[`obj'] Line 19 Column 3 File C:/temp/test.m)IDENTIFIER
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e560[`selector'] Line 19 Column 7 File C:/temp/test.m)IDENTIFIER
| | )postfix_expression
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e760[`sel'] Line 19 Column 18 File C:/temp/test.m)IDENTIFIER
| |)assignment_expression
| )expression_statement
| (expression_statement@C~ObjectiveCv2=400#422e6e0 Line 20 Column 3 File C:/temp/test.m
| |(assignment_expression@C~ObjectiveCv2=356#422e800 Line 20 Column 3 File C:/temp/test.m
| | (postfix_expression@C~ObjectiveCv2=130#422e840 Line 20 Column 3 File C:/temp/test.m
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e580[`obj'] Line 20 Column 3 File C:/temp/test.m)IDENTIFIER
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e6a0[`completionHandler'] Line 20 Column 7 File C:/temp/test.m)IDENTIFIER
| | )postfix_expression
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e860[`completionHandler'] Line 20 Column 27 File C:/temp/test.m)IDENTIFIER
| |)assignment_expression
| )expression_statement
| (expression_statement@C~ObjectiveCv2=400#422e900 Line 21 Column 3 File C:/temp/test.m
| |(assignment_expression@C~ObjectiveCv2=356#422e960 Line 21 Column 3 File C:/temp/test.m
| | (postfix_expression@C~ObjectiveCv2=130#422e8a0 Line 21 Column 3 File C:/temp/test.m
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e820[`obj'] Line 21 Column 3 File C:/temp/test.m)IDENTIFIER
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e7a0[`thread'] Line 21 Column 7 File C:/temp/test.m)IDENTIFIER
| | )postfix_expression
| | (IDENTIFIER@C~ObjectiveCv2=1270#422e940[`thread'] Line 21 Column 16 File C:/temp/test.m)IDENTIFIER
| |)assignment_expression
| )expression_statement
| (jump_statement@C~ObjectiveCv2=487#422e9c0 Line 22 Column 3 File C:/temp/test.m
| |(IDENTIFIER@C~ObjectiveCv2=1270#422e880[`obj'] Line 22 Column 10 File C:/temp/test.m)IDENTIFIER
| )jump_statement
| )statement_seq
| )compound_statement
|)class_method_definition
)implementation_definition_list
(instance_method_definition@C~ObjectiveCv2=1088#422f280 Line 25 Column 1 File C:/temp/test.m
|(AMBIGUITY<method_result_option=527>@C~ObjectiveCv2=1390#4229f40{2} Line 25 Column 3 File C:/temp/test.m
| (method_result_option@C~ObjectiveCv2=1101#422ea60 Line 25 Column 3 File C:/temp/test.m)method_result_option
| (method_type@C~ObjectiveCv2=1103#422e7c0 Line 25 Column 3 File C:/temp/test.m
| (simple_type_specifier@C~ObjectiveCv2=545#422e9e0 Line 25 Column 4 File C:/temp/test.m)simple_type_specifier
| )method_type
|)AMBIGUITY
|(IDENTIFIER@C~ObjectiveCv2=1270#422e8e0[`dealloc'] Line 25 Column 9 File C:/temp/test.m)IDENTIFIER
|(declaration_star@C~ObjectiveCv2=1085#422e7e0 Line 25 Column 17 File C:/temp/test.m)declaration_star
|(compound_statement@C~ObjectiveCv2=403#422efa0 Line 25 Column 17 File C:/temp/test.m
| (statement_seq@C~ObjectiveCv2=405#422ecc0 {7} Line 26 Column 3 File C:/temp/test.m
| (expression_statement@C~ObjectiveCv2=400#422eb40 Line 26 Column 3 File C:/temp/test.m
| (assignment_expression@C~ObjectiveCv2=356#422eb20 Line 26 Column 3 File C:/temp/test.m
| |(postfix_expression@C~ObjectiveCv2=130#422eae0 Line 26 Column 3 File C:/temp/test.m
| | (primary_expression@C~ObjectiveCv2=1155#422ea80 Line 26 Column 3 File C:/temp/test.m)primary_expression
| | (IDENTIFIER@C~ObjectiveCv2=1270#422eaa0[`request'] Line 26 Column 8 File C:/temp/test.m)IDENTIFIER
| |)postfix_expression
| |(primary_expression@C~ObjectiveCv2=1157#422eb00 Line 26 Column 18 File C:/temp/test.m)primary_expression
| )assignment_expression
| )expression_statement
| (expression_statement@C~ObjectiveCv2=400#422eca0 Line 27 Column 3 File C:/temp/test.m
| (assignment_expression@C~ObjectiveCv2=356#422ec40 Line 27 Column 3 File C:/temp/test.m
| |(postfix_expression@C~ObjectiveCv2=130#422ec00 Line 27 Column 3 File C:/temp/test.m
| | (primary_expression@C~ObjectiveCv2=1155#422eba0 Line 27 Column 3 File C:/temp/test.m)primary_expression
| | (IDENTIFIER@C~ObjectiveCv2=1270#422ebc0[`delegate'] Line 27 Column 8 File C:/temp/test.m)IDENTIFIER
| |)postfix_expression
| |(primary_expression@C~ObjectiveCv2=1157#422ec20 Line 27 Column 19 File C:/temp/test.m)primary_expression
| )assignment_expression
| )expression_statement
| (expression_statement@C~ObjectiveCv2=400#422ee20 Line 28 Column 3 File C:/temp/test.m
| (assignment_expression@C~ObjectiveCv2=356#422ee00 Line 28 Column 3 File C:/temp/test.m
| |(postfix_expression@C~ObjectiveCv2=130#422ed60 Line 28 Column 3 File C:/temp/test.m
| | (primary_expression@C~ObjectiveCv2=1155#422ece0 Line 28 Column 3 File C:/temp/test.m)primary_expression
| | (IDENTIFIER@C~ObjectiveCv2=1270#422ed40[`selector'] Line 28 Column 8 File C:/temp/test.m)IDENTIFIER
| |)postfix_expression
| |(IDENTIFIER@C~ObjectiveCv2=1270#422edc0[`NULL'] Line 28 Column 19 File C:/temp/test.m)IDENTIFIER
| )assignment_expression
| )expression_statement
| (expression_statement@C~ObjectiveCv2=400#422ef40 Line 29 Column 3 File C:/temp/test.m
| (assignment_expression@C~ObjectiveCv2=356#422ef20 Line 29 Column 3 File C:/temp/test.m
| |(postfix_expression@C~ObjectiveCv2=130#422eee0 Line 29 Column 3 File C:/temp/test.m
| | (primary_expression@C~ObjectiveCv2=1155#422ee60 Line 29 Column 3 File C:/temp/test.m)primary_expression
| | (IDENTIFIER@C~ObjectiveCv2=1270#422eec0[`completionHandler'] Line 29 Column 8 File C:/temp/test.m)IDENTIFIER
| |)postfix_expression
| |(primary_expression@C~ObjectiveCv2=1157#422ef00 Line 29 Column 28 File C:/temp/test.m)primary_expression
| )assignment_expression
| )expression_statement
| (expression_statement@C~ObjectiveCv2=400#422ee80 Line 30 Column 3 File C:/temp/test.m
| (assignment_expression@C~ObjectiveCv2=356#422efe0 Line 30 Column 3 File C:/temp/test.m
| |(postfix_expression@C~ObjectiveCv2=130#422f020 Line 30 Column 3 File C:/temp/test.m
| | (primary_expression@C~ObjectiveCv2=1155#422ee40 Line 30 Column 3 File C:/temp/test.m)primary_expression
| | (IDENTIFIER@C~ObjectiveCv2=1270#422f000[`thread'] Line 30 Column 8 File C:/temp/test.m)IDENTIFIER
| |)postfix_expression
| |(primary_expression@C~ObjectiveCv2=1157#422efc0 Line 30 Column 17 File C:/temp/test.m)primary_expression
| )assignment_expression
| )expression_statement
| (expression_statement@C~ObjectiveCv2=400#422ef80 Line 31 Column 3 File C:/temp/test.m
| (assignment_expression@C~ObjectiveCv2=356#422f0c0 Line 31 Column 3 File C:/temp/test.m
| |(postfix_expression@C~ObjectiveCv2=130#422f100 Line 31 Column 3 File C:/temp/test.m
| | (primary_expression@C~ObjectiveCv2=1155#422ef60 Line 31 Column 3 File C:/temp/test.m)primary_expression
| | (IDENTIFIER@C~ObjectiveCv2=1270#422f060[`error'] Line 31 Column 8 File C:/temp/test.m)IDENTIFIER
| |)postfix_expression
| |(primary_expression@C~ObjectiveCv2=1157#422f120 Line 31 Column 16 File C:/temp/test.m)primary_expression
| )assignment_expression
| )expression_statement
| (expression_statement@C~ObjectiveCv2=400#422f1a0 Line 32 Column 3 File C:/temp/test.m
| (primary_expression@C~ObjectiveCv2=1158#422f180 Line 32 Column 3 File C:/temp/test.m
| |(primary_expression@C~ObjectiveCv2=1156#422f1e0 Line 32 Column 4 File C:/temp/test.m)primary_expression
| |(IDENTIFIER@C~ObjectiveCv2=1270#422f040[`dealloc'] Line 32 Column 10 File C:/temp/test.m)IDENTIFIER
| )primary_expression
| )expression_statement
| )statement_seq
|)compound_statement
)instance_method_definition
)implementation_definition_list
)class_implementation
)translation_unit
Exiting with final status 0
Because the tree's shape is isomorphic to the grammar we use, the grammar is the documentation. See a previous SO answer for how we do this and yet produce an AST.
This is a code fragment taken from a popular library; it is just a fragment because otherwise the tree would be enormous. I also cheated a tiny bit, by leaving out the #imports, which let me run an easily configured parser. DMS will parse files containing #includes and retain the directive or retain the include text, depend on how its parser is configured.
This is for ObjectiveC, not ObjectiveC++. We're working on that :-}
DMS provides a lot of additional support for program analysis that operates on the ASTs it produces.
Try -Xclang -ast-dump
instead of -cc1 -ast-dump
. (Standard disclaimer: anything using -Xclang
or -cc1
is using an unstable interface to the compiler.)