8

necesito para analizar código estático-Objective C, principalmente AST, después de mirar en las posibles herramientas que he encontrado que la herramienta Sonido metálico de LLVM puede volcar la AST, por lo que utiliza el terminal para poner a prueba utilizando el siguiente comando:¿Cómo extraer AST del código Objective-C?

clang -cc1 -ast-dump ~/SomeTest.m 

pero estoy recibiendo este 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 [email protected] 
@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. 

Cualquier idea de por qué me estoy haciendo esto? No me importa usar cualquier herramienta para extraer AST del código Objective-C, siempre que sea confiable y proporcione documentación para la salida

+0

Hola, ¿Has logrado encontrar un analizador para extraer AST del código fuente del objetivo C? ¡Gracias! – ramo

Respuesta

2

El compilador no encuentra el marco UIKit. Tienes que decirle a utilizarlo:

clang -framework UIKit -cc1 -ast-dump ~/SomeTest.m 
+0

Obteniendo esto clang: advertencia: argumento no utilizado durante la compilación: '-cc1' clang: advertencia: argumento no utilizado durante la compilación: '-ast-dump' En el archivo incluido en /Users/myusername/SomeTest.m:9: /Users/myusername/SomeTest.h:9:9: error grave: no se encontró el archivo 'UIKit/UIKit.h' #import ^ 1 error generado. –

0

Trate -Xclang -ast-dump en lugar de -cc1 -ast-dump. (Exención de responsabilidad estándar: cualquier cosa usando -Xclang o -cc1 está utilizando una interfaz inestable para el compilador.)

+0

sigue recibiendo exactamente los mismos errores publicados en la pregunta :( –

+0

Tome un comando que funcione para compilar el archivo en cuestión, luego agregue -Xclang -ast-dump a ese comando. De lo contrario, terminará con resultados extraños ; el AST para un archivo ObjC depende de las opciones de línea de comandos. – servn

+0

No entendí tu punto. ¿Puedes reformularlo por mí? –

0

OP dice no me importa utilizar cualquier herramienta para extraer AST a partir del código de Objective-C ...

Nuestro DMS Software Reengingineering Toolkit puede hacer esto para Objective-C.

Para esta línea de comandos para el analizador "domainparser" generado por el DMS:

run \DMS\Domains\C\ObjectiveCv2\Tools\Parser\domainparser ++AST "C:\temp\test.m" 

este archivo Objetivo C "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 

produce esta salida con un AST:

Domain Parser for C~ObjectiveCv2 2.4.4 
Copyright (C) Semantic Designs 1996-2012; All Rights Reserved 
([email protected]~ObjectiveCv2=2#422f080^0 Line 1 Column 1 File C:/temp/test.m 
([email protected]~ObjectiveCv2=1048#422f140 Line 1 Column 1 File C:/temp/test.m 
    ([email protected]~ObjectiveCv2=1270#4228b40[`GTLClientLoginAuthorizationArgs'] Line 1 Column 17 File C:/temp/test.m)IDENTIFIER 
    ([email protected]~ObjectiveCv2=1046#4228b80 Line 3 Column 1 File C:/temp/test.m)super_class_option 
    ([email protected]~ObjectiveCv2=1061#4228bc0 Line 3 Column 1 File C:/temp/test.m)instance_variables 
    ([email protected]~ObjectiveCv2=1079#422f0a0 Line 3 Column 1 File C:/temp/test.m 
    ([email protected]~ObjectiveCv2=1079#422e8c0 Line 3 Column 1 File C:/temp/test.m 
    |([email protected]~ObjectiveCv2=1079#42290a0 Line 3 Column 1 File C:/temp/test.m 
    | ([email protected]~ObjectiveCv2=1078#4228c00 Line 3 Column 1 File C:/temp/test.m)implementation_definition_list 
    | ([email protected]~ObjectiveCv2=1131#4229080 Line 3 Column 1 File C:/temp/test.m 
    | ([email protected]~ObjectiveCv2=1134#4229060 Line 3 Column 13 File C:/temp/test.m 
    | ([email protected]~ObjectiveCv2=1134#4228fc0 Line 3 Column 13 File C:/temp/test.m 
    | |([email protected]~ObjectiveCv2=1134#4228f40 Line 3 Column 13 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1134#4228e80 Line 3 Column 13 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1134#4228de0 Line 3 Column 13 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1133#4228d00 Line 3 Column 13 File C:/temp/test.m 
    | | |([email protected]~ObjectiveCv2=1136#4228cc0 Line 3 Column 13 File C:/temp/test.m 
    | | | ([email protected]~ObjectiveCv2=1270#4228c40[`request'] Line 3 Column 13 File C:/temp/test.m)IDENTIFIER 
    | | | ([email protected]~ObjectiveCv2=1270#4228c80[`request_'] Line 3 Column 23 File C:/temp/test.m)IDENTIFIER 
    | | |)property_synthesize_item 
    | | )property_synthesize_list 
    | | ([email protected]~ObjectiveCv2=1136#4228dc0 Line 4 Column 13 File C:/temp/test.m 
    | | |([email protected]~ObjectiveCv2=1270#4228d80[`delegate'] Line 4 Column 13 File C:/temp/test.m)IDENTIFIER 
    | | |([email protected]~ObjectiveCv2=1270#4228da0[`delegate_'] Line 4 Column 24 File C:/temp/test.m)IDENTIFIER 
    | | )property_synthesize_item 
    | | )property_synthesize_list 
    | | ([email protected]~ObjectiveCv2=1136#4228e60 Line 5 Column 13 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1270#4228e20[`selector'] Line 5 Column 13 File C:/temp/test.m)IDENTIFIER 
    | | ([email protected]~ObjectiveCv2=1270#4228e40[`sel_'] Line 5 Column 24 File C:/temp/test.m)IDENTIFIER 
    | | )property_synthesize_item 
    | |)property_synthesize_list 
    | | ([email protected]~ObjectiveCv2=1136#4228f20 Line 6 Column 13 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1270#4228ea0[`completionHandler'] Line 6 Column 13 File C:/temp/test.m)IDENTIFIER 
    | | ([email protected]~ObjectiveCv2=1270#4228f00[`completionHandler_'] Line 6 Column 33 File C:/temp/test.m)IDENTIFIER 
    | |)property_synthesize_item 
    | |)property_synthesize_list 
    | |([email protected]~ObjectiveCv2=1136#4228fa0 Line 7 Column 13 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1270#4228f60[`thread'] Line 7 Column 13 File C:/temp/test.m)IDENTIFIER 
    | | ([email protected]~ObjectiveCv2=1270#4228f80[`thread_'] Line 7 Column 22 File C:/temp/test.m)IDENTIFIER 
    | |)property_synthesize_item 
    | )property_synthesize_list 
    | ([email protected]~ObjectiveCv2=1136#4229040 Line 8 Column 13 File C:/temp/test.m 
    | |([email protected]~ObjectiveCv2=1270#4228fe0[`error'] Line 8 Column 13 File C:/temp/test.m)IDENTIFIER 
    | |([email protected]~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 
    |([email protected]~ObjectiveCv2=1087#422ea00 Line 10 Column 1 File C:/temp/test.m 
    | ([email protected]~ObjectiveCv2=1103#4229200 Line 10 Column 3 File C:/temp/test.m 
    | ([email protected]~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 
    | |([email protected]~ObjectiveCv2=1144#4229100 Line 10 Column 4 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1270#42290c0^2#4228ca0:2#4229100:1[`GTLClientLoginAuthorizationArgs'] Line 10 Column 4 File C:/temp/test.m)IDENTIFIER 
    | | ([email protected]~ObjectiveCv2=1057#42290e0 Line 10 Column 36 File C:/temp/test.m)protocol_option 
    | |)type_specifier 
    | |([email protected]~ObjectiveCv2=1270#42290c0^2#4228ca0:2#4229100:1... [ALREADY PRINTED] ...) 
    | )AMBIGUITY 
    | ([email protected]~ObjectiveCv2=640#4229120 Line 10 Column 36 File C:/temp/test.m)ptr_operator 
    | )type_id 
    |)method_type 
    | ([email protected]~ObjectiveCv2=1095#4229940 Line 10 Column 38 File C:/temp/test.m 
    | ([email protected]~ObjectiveCv2=1095#4229720 Line 10 Column 38 File C:/temp/test.m 
    | ([email protected]~ObjectiveCv2=1095#42296a0 Line 10 Column 38 File C:/temp/test.m 
    | |([email protected]~ObjectiveCv2=1095#4229580 Line 10 Column 38 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1094#42294a0 Line 10 Column 38 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1099#4229480 Line 10 Column 38 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1270#42291e0[`argsWithRequest'] Line 10 Column 38 File C:/temp/test.m)IDENTIFIER 
    | | ([email protected]~ObjectiveCv2=1103#4229440 Line 10 Column 54 File C:/temp/test.m 
    | | |([email protected]~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 
    | | | ([email protected]~ObjectiveCv2=1144#42292a0 Line 10 Column 55 File C:/temp/test.m 
    | | | ([email protected]~ObjectiveCv2=1270#4229220^2#4229300:2#42292a0:1[`NSMutableURLRequest'] Line 10 Column 55 File C:/temp/test.m)IDENTIFIER 
    | | | ([email protected]~ObjectiveCv2=1057#4229260 Line 10 Column 75 File C:/temp/test.m)protocol_option 
    | | | )type_specifier 
    | | | ([email protected]~ObjectiveCv2=1270#4229220^2#4229300:2#42292a0:1... [ALREADY PRINTED] ...) 
    | | |)AMBIGUITY 
    | | | ([email protected]~ObjectiveCv2=640#42293a0 Line 10 Column 75 File C:/temp/test.m)ptr_operator 
    | | |)type_id 
    | | )method_type 
    | | ([email protected]~ObjectiveCv2=1270#42293e0[`req'] Line 10 Column 77 File C:/temp/test.m)IDENTIFIER 
    | | )keyword_declarator 
    | |)keyword_selector 
    | | ([email protected]~ObjectiveCv2=1099#4229600 Line 11 Column 45 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1270#4229460[`delegate'] Line 11 Column 45 File C:/temp/test.m)IDENTIFIER 
    | | ([email protected]~ObjectiveCv2=1103#4228d40 Line 11 Column 54 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1143#42294e0 Line 11 Column 55 File C:/temp/test.m 
    | | |([email protected]~ObjectiveCv2=1057#4229500 Line 11 Column 57 File C:/temp/test.m)protocol_option 
    | | )type_specifier 
    | | )method_type 
    | | ([email protected]~ObjectiveCv2=1270#4228d20[`delegate'] Line 11 Column 58 File C:/temp/test.m)IDENTIFIER 
    | |)keyword_declarator 
    | |)keyword_selector 
    | |([email protected]~ObjectiveCv2=1099#4229680 Line 12 Column 45 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1270#42295a0[`selector'] Line 12 Column 45 File C:/temp/test.m)IDENTIFIER 
    | | ([email protected]~ObjectiveCv2=1103#4229280 Line 12 Column 54 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1141#42295c0 Line 12 Column 55 File C:/temp/test.m)simple_type_specifier 
    | |)method_type 
    | | ([email protected]~ObjectiveCv2=1270#4229560[`sel'] Line 12 Column 59 File C:/temp/test.m)IDENTIFIER 
    | |)keyword_declarator 
    | )keyword_selector 
    | ([email protected]~ObjectiveCv2=1099#4229700 Line 13 Column 36 File C:/temp/test.m 
    | |([email protected]~ObjectiveCv2=1270#4229520[`completionHandler'] Line 13 Column 36 File C:/temp/test.m)IDENTIFIER 
    | |([email protected]~ObjectiveCv2=1103#42294c0 Line 13 Column 54 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1143#42296c0 Line 13 Column 55 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1057#42296e0 Line 13 Column 57 File C:/temp/test.m)protocol_option 
    | |)type_specifier 
    | |)method_type 
    | |([email protected]~ObjectiveCv2=1270#4228c60[`completionHandler'] Line 13 Column 58 File C:/temp/test.m)IDENTIFIER 
    | )keyword_declarator 
    | )keyword_selector 
    | ([email protected]~ObjectiveCv2=1099#4229920 Line 14 Column 47 File C:/temp/test.m 
    | ([email protected]~ObjectiveCv2=1270#4229760[`thread'] Line 14 Column 47 File C:/temp/test.m)IDENTIFIER 
    | ([email protected]~ObjectiveCv2=1103#4229900 Line 14 Column 54 File C:/temp/test.m 
    | |([email protected]~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 
    | | ([email protected]~ObjectiveCv2=1144#42297e0 Line 14 Column 55 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1270#42297c0^2#4229320:2#42297e0:1[`NSThread'] Line 14 Column 55 File C:/temp/test.m)IDENTIFIER 
    | | ([email protected]~ObjectiveCv2=1057#4229740 Line 14 Column 64 File C:/temp/test.m)protocol_option 
    | | )type_specifier 
    | | ([email protected]~ObjectiveCv2=1270#42297c0^2#4229320:2#42297e0:1... [ALREADY PRINTED] ...) 
    | |)AMBIGUITY 
    | | ([email protected]~ObjectiveCv2=640#4229840 Line 14 Column 64 File C:/temp/test.m)ptr_operator 
    | |)type_id 
    | )method_type 
    | ([email protected]~ObjectiveCv2=1270#42298c0[`thread'] Line 14 Column 66 File C:/temp/test.m)IDENTIFIER 
    | )keyword_declarator 
    |)keyword_selector 
    | ([email protected]~ObjectiveCv2=1085#4229980 Line 14 Column 73 File C:/temp/test.m)declaration_star 
    | ([email protected]~ObjectiveCv2=403#422e920 Line 14 Column 73 File C:/temp/test.m 
    | ([email protected]~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 
    | |([email protected]~ObjectiveCv2=400#422e200 Line 15 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=209#4229e60 Line 15 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1270#42299e0^3#42297a0:1#4229a80:1#4229e60:1[`GTLClientLoginAuthorizationArgs'] Line 15 Column 3 File C:/temp/test.m)IDENTIFIER 
    | | ([email protected]~ObjectiveCv2=1270#4229ca0^2#4229d60:2#4229e60:2[`obj'] Line 15 Column 36 File C:/temp/test.m)IDENTIFIER 
    | |)multiplicative_expression 
    | |)expression_statement 
    | |([email protected]~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 
    | | ([email protected]~ObjectiveCv2=1270#42299e0^3#42297a0:1#4229a80:1#4229e60:1... [ALREADY PRINTED] ...) 
    | | ([email protected]~ObjectiveCv2=1144#4229a80 Line 15 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1270#42299e0^3#42297a0:1#4229a80:1#4229e60:1... [ALREADY PRINTED] ...) 
    | | ([email protected]~ObjectiveCv2=1057#4229a20 Line 15 Column 35 File C:/temp/test.m)protocol_option 
    | | )type_specifier 
    | |)AMBIGUITY 
    | | ([email protected]~ObjectiveCv2=624#4229d60 Line 15 Column 35 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=640#4229cc0 Line 15 Column 35 File C:/temp/test.m)ptr_operator 
    | | ([email protected]~ObjectiveCv2=1270#4229ca0^2#4229d60:2#4229e60:2... [ALREADY PRINTED] ...) 
    | |)declarator 
    | |)simple_declaration 
    | )AMBIGUITY 
    | ([email protected]~ObjectiveCv2=400#422e3c0 Line 16 Column 3 File C:/temp/test.m 
    | |([email protected]~ObjectiveCv2=356#422e360 Line 16 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1270#422e1c0[`obj'] Line 16 Column 3 File C:/temp/test.m)IDENTIFIER 
    | | ([email protected]~ObjectiveCv2=1158#422e340 Line 16 Column 9 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1158#422e320 Line 16 Column 10 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1158#422e2e0 Line 16 Column 11 File C:/temp/test.m 
    | | |([email protected]~ObjectiveCv2=1270#422e220[`GTLClientLoginAuthorizationArgs'] Line 16 Column 12 File C:/temp/test.m)IDENTIFIER 
    | | |([email protected]~ObjectiveCv2=1270#422e2a0[`alloc'] Line 16 Column 44 File C:/temp/test.m)IDENTIFIER 
    | | )primary_expression 
    | | ([email protected]~ObjectiveCv2=1270#422e2c0[`init'] Line 16 Column 51 File C:/temp/test.m)IDENTIFIER 
    | | )primary_expression 
    | | ([email protected]~ObjectiveCv2=1270#422e300[`autorelease'] Line 16 Column 57 File C:/temp/test.m)IDENTIFIER 
    | |)primary_expression 
    | |)assignment_expression 
    | )expression_statement 
    | ([email protected]~ObjectiveCv2=400#422e540 Line 17 Column 3 File C:/temp/test.m 
    | |([email protected]~ObjectiveCv2=356#422e500 Line 17 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=130#422e480 Line 17 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1270#422e380[`obj'] Line 17 Column 3 File C:/temp/test.m)IDENTIFIER 
    | | ([email protected]~ObjectiveCv2=1270#422e440[`request'] Line 17 Column 7 File C:/temp/test.m)IDENTIFIER 
    | |)postfix_expression 
    | | ([email protected]~ObjectiveCv2=1270#422e4a0[`req'] Line 17 Column 17 File C:/temp/test.m)IDENTIFIER 
    | |)assignment_expression 
    | )expression_statement 
    | ([email protected]~ObjectiveCv2=400#422e680 Line 18 Column 3 File C:/temp/test.m 
    | |([email protected]~ObjectiveCv2=356#422e640 Line 18 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=130#422e600 Line 18 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1270#422e520[`obj'] Line 18 Column 3 File C:/temp/test.m)IDENTIFIER 
    | | ([email protected]~ObjectiveCv2=1270#422e5c0[`delegate'] Line 18 Column 7 File C:/temp/test.m)IDENTIFIER 
    | |)postfix_expression 
    | | ([email protected]~ObjectiveCv2=1270#422e620[`delegate'] Line 18 Column 18 File C:/temp/test.m)IDENTIFIER 
    | |)assignment_expression 
    | )expression_statement 
    | ([email protected]~ObjectiveCv2=400#422e780 Line 19 Column 3 File C:/temp/test.m 
    | |([email protected]~ObjectiveCv2=356#422e720 Line 19 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=130#422e740 Line 19 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1270#422e660[`obj'] Line 19 Column 3 File C:/temp/test.m)IDENTIFIER 
    | | ([email protected]~ObjectiveCv2=1270#422e560[`selector'] Line 19 Column 7 File C:/temp/test.m)IDENTIFIER 
    | |)postfix_expression 
    | | ([email protected]~ObjectiveCv2=1270#422e760[`sel'] Line 19 Column 18 File C:/temp/test.m)IDENTIFIER 
    | |)assignment_expression 
    | )expression_statement 
    | ([email protected]~ObjectiveCv2=400#422e6e0 Line 20 Column 3 File C:/temp/test.m 
    | |([email protected]~ObjectiveCv2=356#422e800 Line 20 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=130#422e840 Line 20 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1270#422e580[`obj'] Line 20 Column 3 File C:/temp/test.m)IDENTIFIER 
    | | ([email protected]~ObjectiveCv2=1270#422e6a0[`completionHandler'] Line 20 Column 7 File C:/temp/test.m)IDENTIFIER 
    | |)postfix_expression 
    | | ([email protected]~ObjectiveCv2=1270#422e860[`completionHandler'] Line 20 Column 27 File C:/temp/test.m)IDENTIFIER 
    | |)assignment_expression 
    | )expression_statement 
    | ([email protected]~ObjectiveCv2=400#422e900 Line 21 Column 3 File C:/temp/test.m 
    | |([email protected]~ObjectiveCv2=356#422e960 Line 21 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=130#422e8a0 Line 21 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1270#422e820[`obj'] Line 21 Column 3 File C:/temp/test.m)IDENTIFIER 
    | | ([email protected]~ObjectiveCv2=1270#422e7a0[`thread'] Line 21 Column 7 File C:/temp/test.m)IDENTIFIER 
    | |)postfix_expression 
    | | ([email protected]~ObjectiveCv2=1270#422e940[`thread'] Line 21 Column 16 File C:/temp/test.m)IDENTIFIER 
    | |)assignment_expression 
    | )expression_statement 
    | ([email protected]~ObjectiveCv2=487#422e9c0 Line 22 Column 3 File C:/temp/test.m 
    | |([email protected]~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 
    ([email protected]~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 
    | ([email protected]~ObjectiveCv2=1101#422ea60 Line 25 Column 3 File C:/temp/test.m)method_result_option 
    | ([email protected]~ObjectiveCv2=1103#422e7c0 Line 25 Column 3 File C:/temp/test.m 
    | ([email protected]~ObjectiveCv2=545#422e9e0 Line 25 Column 4 File C:/temp/test.m)simple_type_specifier 
    |)method_type 
    |)AMBIGUITY 
    |([email protected]~ObjectiveCv2=1270#422e8e0[`dealloc'] Line 25 Column 9 File C:/temp/test.m)IDENTIFIER 
    |([email protected]~ObjectiveCv2=1085#422e7e0 Line 25 Column 17 File C:/temp/test.m)declaration_star 
    |([email protected]~ObjectiveCv2=403#422efa0 Line 25 Column 17 File C:/temp/test.m 
    | ([email protected]~ObjectiveCv2=405#422ecc0 {7} Line 26 Column 3 File C:/temp/test.m 
    | ([email protected]~ObjectiveCv2=400#422eb40 Line 26 Column 3 File C:/temp/test.m 
    | ([email protected]~ObjectiveCv2=356#422eb20 Line 26 Column 3 File C:/temp/test.m 
    | |([email protected]~ObjectiveCv2=130#422eae0 Line 26 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1155#422ea80 Line 26 Column 3 File C:/temp/test.m)primary_expression 
    | | ([email protected]~ObjectiveCv2=1270#422eaa0[`request'] Line 26 Column 8 File C:/temp/test.m)IDENTIFIER 
    | |)postfix_expression 
    | |([email protected]~ObjectiveCv2=1157#422eb00 Line 26 Column 18 File C:/temp/test.m)primary_expression 
    | )assignment_expression 
    | )expression_statement 
    | ([email protected]~ObjectiveCv2=400#422eca0 Line 27 Column 3 File C:/temp/test.m 
    | ([email protected]~ObjectiveCv2=356#422ec40 Line 27 Column 3 File C:/temp/test.m 
    | |([email protected]~ObjectiveCv2=130#422ec00 Line 27 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1155#422eba0 Line 27 Column 3 File C:/temp/test.m)primary_expression 
    | | ([email protected]~ObjectiveCv2=1270#422ebc0[`delegate'] Line 27 Column 8 File C:/temp/test.m)IDENTIFIER 
    | |)postfix_expression 
    | |([email protected]~ObjectiveCv2=1157#422ec20 Line 27 Column 19 File C:/temp/test.m)primary_expression 
    | )assignment_expression 
    | )expression_statement 
    | ([email protected]~ObjectiveCv2=400#422ee20 Line 28 Column 3 File C:/temp/test.m 
    | ([email protected]~ObjectiveCv2=356#422ee00 Line 28 Column 3 File C:/temp/test.m 
    | |([email protected]~ObjectiveCv2=130#422ed60 Line 28 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1155#422ece0 Line 28 Column 3 File C:/temp/test.m)primary_expression 
    | | ([email protected]~ObjectiveCv2=1270#422ed40[`selector'] Line 28 Column 8 File C:/temp/test.m)IDENTIFIER 
    | |)postfix_expression 
    | |([email protected]~ObjectiveCv2=1270#422edc0[`NULL'] Line 28 Column 19 File C:/temp/test.m)IDENTIFIER 
    | )assignment_expression 
    | )expression_statement 
    | ([email protected]~ObjectiveCv2=400#422ef40 Line 29 Column 3 File C:/temp/test.m 
    | ([email protected]~ObjectiveCv2=356#422ef20 Line 29 Column 3 File C:/temp/test.m 
    | |([email protected]~ObjectiveCv2=130#422eee0 Line 29 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1155#422ee60 Line 29 Column 3 File C:/temp/test.m)primary_expression 
    | | ([email protected]~ObjectiveCv2=1270#422eec0[`completionHandler'] Line 29 Column 8 File C:/temp/test.m)IDENTIFIER 
    | |)postfix_expression 
    | |([email protected]~ObjectiveCv2=1157#422ef00 Line 29 Column 28 File C:/temp/test.m)primary_expression 
    | )assignment_expression 
    | )expression_statement 
    | ([email protected]~ObjectiveCv2=400#422ee80 Line 30 Column 3 File C:/temp/test.m 
    | ([email protected]~ObjectiveCv2=356#422efe0 Line 30 Column 3 File C:/temp/test.m 
    | |([email protected]~ObjectiveCv2=130#422f020 Line 30 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1155#422ee40 Line 30 Column 3 File C:/temp/test.m)primary_expression 
    | | ([email protected]~ObjectiveCv2=1270#422f000[`thread'] Line 30 Column 8 File C:/temp/test.m)IDENTIFIER 
    | |)postfix_expression 
    | |([email protected]~ObjectiveCv2=1157#422efc0 Line 30 Column 17 File C:/temp/test.m)primary_expression 
    | )assignment_expression 
    | )expression_statement 
    | ([email protected]~ObjectiveCv2=400#422ef80 Line 31 Column 3 File C:/temp/test.m 
    | ([email protected]~ObjectiveCv2=356#422f0c0 Line 31 Column 3 File C:/temp/test.m 
    | |([email protected]~ObjectiveCv2=130#422f100 Line 31 Column 3 File C:/temp/test.m 
    | | ([email protected]~ObjectiveCv2=1155#422ef60 Line 31 Column 3 File C:/temp/test.m)primary_expression 
    | | ([email protected]~ObjectiveCv2=1270#422f060[`error'] Line 31 Column 8 File C:/temp/test.m)IDENTIFIER 
    | |)postfix_expression 
    | |([email protected]~ObjectiveCv2=1157#422f120 Line 31 Column 16 File C:/temp/test.m)primary_expression 
    | )assignment_expression 
    | )expression_statement 
    | ([email protected]~ObjectiveCv2=400#422f1a0 Line 32 Column 3 File C:/temp/test.m 
    | ([email protected]~ObjectiveCv2=1158#422f180 Line 32 Column 3 File C:/temp/test.m 
    | |([email protected]~ObjectiveCv2=1156#422f1e0 Line 32 Column 4 File C:/temp/test.m)primary_expression 
    | |([email protected]~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 

Como la forma del árbol es isomorfa a la gramática que utilizamos, la gramática i s la documentación. Vea una respuesta SO anterior para how we do this and yet produce an AST.

Este es un fragmento de código tomado de una biblioteca popular; es solo un fragmento porque de lo contrario el árbol sería enorme. También hice trampa un poco, al dejar de lado las #importaciones, lo que me permitió ejecutar un analizador de configuración fácil. DMS analizará los archivos que contengan #includes y retendrá la directiva o retendrá el texto incluido, dependiendo de cómo esté configurado su analizador.

Esto es para ObjectiveC, no ObjectiveC++. Estamos trabajando en eso: -}

DMS proporciona una gran cantidad de soporte adicional para el análisis de programas que opera en los AST que produce.

+0

Gracias, infractor. Esta respuesta proporciona una respuesta específica a la solicitud de OP y muestra exactamente cómo hacer lo que quiere. ¿Cuál es su razón para rechazar? –