Compare commits

...

5 Commits

Author SHA1 Message Date
Shadowfacts b856c0ad2e Use --abi=14 2022-05-29 11:02:30 -04:00
shengxuanwei 626b5287fe FIX: Cargo version to 2021 2022-05-01 18:43:36 +08:00
shengxuanwei 8e2d230c29 MOD: move attribute specifiers to @attribute 2022-04-24 16:29:47 +08:00
shengxuanwei 978c89dccf MOD: update test cases 2022-04-24 16:04:02 +08:00
shengxuanwei f5935e2b40 FIX: typdef NS_ENUM declarator MISSING 2022-04-24 15:34:42 +08:00
13 changed files with 525082 additions and 505092 deletions

View File

@ -7,7 +7,7 @@ license = "MIT"
keywords = ["tree-sitter", "incremental", "parsing", "objc"] keywords = ["tree-sitter", "incremental", "parsing", "objc"]
categories = ["parsing", "text-editors"] categories = ["parsing", "text-editors"]
repository = "https://github.com/jiyee/tree-sitter-objc" repository = "https://github.com/jiyee/tree-sitter-objc"
edition = "2022" edition = "2021"
build = "bindings/rust/build.rs" build = "bindings/rust/build.rs"
include = [ include = [

View File

@ -35,7 +35,7 @@ pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
// Uncomment these to include any queries that this grammar contains // Uncomment these to include any queries that this grammar contains
// pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm"); pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm"); // pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
// pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm"); // pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
// pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm"); // pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");

View File

@ -1343,6 +1343,39 @@ typedef id (*NSNumberAllocImp)(id receiver, SEL selector);
typedef void (*mtl_failedMethodCallback)(Class, Method); typedef void (*mtl_failedMethodCallback)(Class, Method);
enum {
UITableViewCellStyleDefault,
UITableViewCellStyleValue1,
UITableViewCellStyleValue2,
UITableViewCellStyleSubtitle
};
typedef enum {
UITableViewCellStyleDefault,
UITableViewCellStyleValue1,
UITableViewCellStyleValue2,
UITableViewCellStyleSubtitle
} UITableViewCellStyle;
typedef enum {
UITableViewCellStyleDefault,
UITableViewCellStyleValue1,
UITableViewCellStyleValue2,
UITableViewCellStyleSubtitle
};
typedef NSInteger UITableViewCellStyle;
// enum attr-spec-seq(optional) identifier(optional) { enumerator-list }
enum week{Mon, Tue, Wed}; // type specifier
enum week day; // declaration, "day" is the declarator
// Every declaration of an enum or a typedef is a definition.
enum week{Mon, Tue, Wed}day; // declaring an enum variable
// "week{Mon, Tue, Wed}" is the type specifier
// "day" is the declarator
typedef NS_ENUM(NSUInteger, RLMSyncStopPolicy); typedef NS_ENUM(NSUInteger, RLMSyncStopPolicy);
typedef NS_ENUM(NSUInteger, SDAnimatedImagePlaybackMode) { typedef NS_ENUM(NSUInteger, SDAnimatedImagePlaybackMode) {
@ -1488,14 +1521,14 @@ typedef struct _AspectBlock {
struct unarchive_list { struct unarchive_list {
int ifield; int ifield;
id *list; id *list;
}; // FIXME };
@end @end
struct type_s { struct type_s {
SS may_recurse; SS may_recurse;
id id_val; id id_val;
}; }; // FIXME
struct Derived : type_s { }; struct Derived : type_s { };

View File

@ -19,8 +19,10 @@ module.exports = grammar(C, {
[$.struct_specifier], [$.struct_specifier],
[$.union_specifier], [$.union_specifier],
[$.enum_specifier], [$.enum_specifier],
[$.ns_enum_specifier],
[$.function_declarator], [$.function_declarator],
[$.type_descriptor], [$.type_descriptor],
[$.type_definition], // field attributes
[$.superclass_reference], [$.superclass_reference],
[$._expression, $.macro_type_specifier], [$._expression, $.macro_type_specifier],
[$._expression, $.generic_type_specifier], [$._expression, $.generic_type_specifier],
@ -144,7 +146,7 @@ module.exports = grammar(C, {
seq($._name, optional($.parameterized_class_type_arguments), optional($.protocol_qualifiers)), seq($._name, optional($.parameterized_class_type_arguments), optional($.protocol_qualifiers)),
$.generics_type_reference $.generics_type_reference
), ),
'(', optional(field('category', $.identifier)),')', '(', field('category', optional($.identifier)),')',
optional($.protocol_qualifiers), optional($.protocol_qualifiers),
optional($._instance_variables), optional($._instance_variables),
optional($._interface_declaration), optional($._interface_declaration),
@ -483,7 +485,7 @@ module.exports = grammar(C, {
field('return_type', optional($._method_argument_type_specifier)), field('return_type', optional($._method_argument_type_specifier)),
field('selector', $._method_selector), field('selector', $._method_selector),
optional($.attribute_specifier), optional($.attribute_specifier),
optional(';'), optional(';'), // compatible with: - (void)method; {}
field('body', $.compound_statement), field('body', $.compound_statement),
optional(';'), optional(';'),
), ),
@ -496,12 +498,12 @@ module.exports = grammar(C, {
), ),
), ),
_unary_selector: $ => $.identifier, // naming _unary_selector: $ => $.identifier,
keyword_selector: $ => repeat1($.keyword_declarator), keyword_selector: $ => repeat1($.keyword_declarator),
keyword_declarator: $ => prec.right(seq( keyword_declarator: $ => prec.right(seq(
field('keyword', optional($.identifier)), // naming field('keyword', optional($.identifier)),
':', ':',
field('type', optional($._method_argument_type_specifier)), field('type', optional($._method_argument_type_specifier)),
$._name, $._name,
@ -532,13 +534,25 @@ module.exports = grammar(C, {
optional($.attribute_specifier), optional($.attribute_specifier),
optional($.swift_name_attribute_sepcifier), optional($.swift_name_attribute_sepcifier),
'typedef', 'typedef',
choice(
seq(
optional($.attribute_specifier), optional($.attribute_specifier),
repeat($.type_qualifier), repeat($.type_qualifier),
field('type', $._type_specifier), field('type', $._type_specifier),
optional($.attribute_specifier), optional($.attribute_specifier),
repeat($.type_qualifier), repeat($.type_qualifier),
optional(field('declarator', $._type_declarator)), // NS_ENUM optional field('declarator', $._type_declarator),
optional(choice(field('attributes', $.identifier), $.attribute_specifier)), ),
seq(
optional($.attribute_specifier),
repeat($.type_qualifier),
field('type', $.ns_enum_specifier),
optional($.attribute_specifier),
repeat($.type_qualifier),
field('declarator', optional($._type_declarator)), // NS_ENUM optional
)
),
field('attributes', optional(choice($.identifier, $.attribute_specifier))),
';' ';'
)), )),
@ -552,8 +566,7 @@ module.exports = grammar(C, {
$.block_abstract_declarator, $.block_abstract_declarator,
), ),
enum_specifier: ($, superclass) => choice( enum_specifier: ($, superclass) => seq(
seq(
'enum', 'enum',
choice( choice(
seq( seq(
@ -564,14 +577,14 @@ module.exports = grammar(C, {
field('body', $.enumerator_list) field('body', $.enumerator_list)
) )
), ),
seq(
ns_enum_specifier: ($, superclass) => seq(
choice('NS_ENUM', 'NS_ERROR_ENUM', 'NS_OPTIONS'), choice('NS_ENUM', 'NS_ERROR_ENUM', 'NS_OPTIONS'),
'(', '(',
field('type', $._type_specifier), field('type', $._type_specifier),
optional(seq(',', field('name', $._type_identifier))), optional(seq(',', field('name', $._type_identifier))),
')', ')',
field('body', optional($.enumerator_list)), field('body', optional($.enumerator_list)),
)
), ),
enumerator: ($, superclass) => seq( enumerator: ($, superclass) => seq(
@ -589,6 +602,7 @@ module.exports = grammar(C, {
$.BOOL, $.BOOL,
$.auto, $.auto,
$.instancetype, $.instancetype,
$.ns_enum_specifier,
$.typeof_specifier, $.typeof_specifier,
$.atomic_specifier, $.atomic_specifier,
$.generic_type_specifier, $.generic_type_specifier,
@ -881,7 +895,7 @@ module.exports = grammar(C, {
keyword_argument_list: $ => repeat1($.keyword_argument), keyword_argument_list: $ => repeat1($.keyword_argument),
keyword_argument: $ => seq( keyword_argument: $ => seq(
optional(field('keyword', $.identifier)), field('keyword', optional($.identifier)),
':', ':',
field('argument', choice( field('argument', choice(
$._expression, $._expression,

View File

@ -50,8 +50,6 @@
"@throw" "@throw"
"@selector" "@selector"
"@encode" "@encode"
"@available"
"__builtin_available"
(private) (private)
(public) (public)
(protected) (protected)
@ -61,11 +59,9 @@
"NS_ENUM" "NS_ENUM"
"NS_ERROR_ENUM" "NS_ERROR_ENUM"
"NS_OPTIONS" "NS_OPTIONS"
"NS_SWIFT_NAME"
(type_qualifier) (type_qualifier)
(storage_class_specifier) (storage_class_specifier)
(attribute_specifier)
(class_interface_attribute_sepcifier)
(method_variadic_arguments_attribute_specifier)
"NS_NOESCAPE" "NS_NOESCAPE"
"const" "const"
"default" "default"
@ -358,6 +354,12 @@ declarator: (identifier) @property
"_unaligned" "_unaligned"
"__unaligned" "__unaligned"
"__declspec" "__declspec"
"__unused"
"__builtin_available"
"@available"
(attribute_specifier)
(class_interface_attribute_sepcifier)
(method_variadic_arguments_attribute_specifier)
] @attribute ] @attribute
(attribute_specifier) @attribute (attribute_specifier) @attribute

View File

@ -1846,6 +1846,12 @@
"type": "STRING", "type": "STRING",
"value": "typedef" "value": "typedef"
}, },
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{ {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
@ -1892,9 +1898,6 @@
"name": "type_qualifier" "name": "type_qualifier"
} }
}, },
{
"type": "CHOICE",
"members": [
{ {
"type": "FIELD", "type": "FIELD",
"name": "declarator", "name": "declarator",
@ -1902,6 +1905,18 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "_type_declarator" "name": "_type_declarator"
} }
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "attribute_specifier"
}, },
{ {
"type": "BLANK" "type": "BLANK"
@ -1909,18 +1924,71 @@
] ]
}, },
{ {
"type": "CHOICE", "type": "REPEAT",
"members": [ "content": {
"type": "SYMBOL",
"name": "type_qualifier"
}
},
{
"type": "FIELD",
"name": "type",
"content": {
"type": "SYMBOL",
"name": "ns_enum_specifier"
}
},
{ {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{
"type": "SYMBOL",
"name": "attribute_specifier"
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "type_qualifier"
}
},
{
"type": "FIELD",
"name": "declarator",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_type_declarator"
},
{
"type": "BLANK"
}
]
}
}
]
}
]
},
{ {
"type": "FIELD", "type": "FIELD",
"name": "attributes", "name": "attributes",
"content": { "content": {
"type": "CHOICE",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL", "type": "SYMBOL",
"name": "identifier" "name": "identifier"
}
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
@ -1932,6 +2000,7 @@
"type": "BLANK" "type": "BLANK"
} }
] ]
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -3309,6 +3378,10 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "instancetype" "name": "instancetype"
}, },
{
"type": "SYMBOL",
"name": "ns_enum_specifier"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "typeof_specifier" "name": "typeof_specifier"
@ -3482,9 +3555,6 @@
} }
}, },
"enum_specifier": { "enum_specifier": {
"type": "CHOICE",
"members": [
{
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
@ -3568,87 +3638,6 @@
} }
] ]
}, },
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "NS_ENUM"
},
{
"type": "STRING",
"value": "NS_ERROR_ENUM"
},
{
"type": "STRING",
"value": "NS_OPTIONS"
}
]
},
{
"type": "STRING",
"value": "("
},
{
"type": "FIELD",
"name": "type",
"content": {
"type": "SYMBOL",
"name": "_type_specifier"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL",
"name": "_type_identifier"
}
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": ")"
},
{
"type": "FIELD",
"name": "body",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "enumerator_list"
},
{
"type": "BLANK"
}
]
}
}
]
}
]
},
"enumerator_list": { "enumerator_list": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
@ -7628,21 +7617,21 @@
"type": "STRING", "type": "STRING",
"value": "(" "value": "("
}, },
{
"type": "CHOICE",
"members": [
{ {
"type": "FIELD", "type": "FIELD",
"name": "category", "name": "category",
"content": { "content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL", "type": "SYMBOL",
"name": "identifier" "name": "identifier"
}
}, },
{ {
"type": "BLANK" "type": "BLANK"
} }
] ]
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -9601,6 +9590,85 @@
] ]
} }
}, },
"ns_enum_specifier": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "NS_ENUM"
},
{
"type": "STRING",
"value": "NS_ERROR_ENUM"
},
{
"type": "STRING",
"value": "NS_OPTIONS"
}
]
},
{
"type": "STRING",
"value": "("
},
{
"type": "FIELD",
"name": "type",
"content": {
"type": "SYMBOL",
"name": "_type_specifier"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL",
"name": "_type_identifier"
}
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": ")"
},
{
"type": "FIELD",
"name": "body",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "enumerator_list"
},
{
"type": "BLANK"
}
]
}
}
]
},
"typeof_specifier": { "typeof_specifier": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
@ -10286,22 +10354,22 @@
}, },
"keyword_argument": { "keyword_argument": {
"type": "SEQ", "type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [ "members": [
{ {
"type": "FIELD", "type": "FIELD",
"name": "keyword", "name": "keyword",
"content": { "content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL", "type": "SYMBOL",
"name": "identifier" "name": "identifier"
}
}, },
{ {
"type": "BLANK" "type": "BLANK"
} }
] ]
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -11242,12 +11310,18 @@
[ [
"enum_specifier" "enum_specifier"
], ],
[
"ns_enum_specifier"
],
[ [
"function_declarator" "function_declarator"
], ],
[ [
"type_descriptor" "type_descriptor"
], ],
[
"type_definition"
],
[ [
"superclass_reference" "superclass_reference"
], ],
@ -11282,6 +11356,7 @@
"precedences": [], "precedences": [],
"externals": [], "externals": [],
"inline": [ "inline": [
"_statement",
"_top_level_item", "_top_level_item",
"_type_identifier", "_type_identifier",
"_field_identifier", "_field_identifier",

View File

@ -1295,6 +1295,10 @@
"type": "method_declaration", "type": "method_declaration",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "optional", "type": "optional",
"named": true "named": true
@ -1584,6 +1588,10 @@
"type": "method_declaration", "type": "method_declaration",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "optional", "type": "optional",
"named": true "named": true
@ -1850,6 +1858,10 @@
"type": "module_import", "type": "module_import",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "preproc_def", "type": "preproc_def",
"named": true "named": true
@ -2035,6 +2047,10 @@
"type": "macro_type_specifier", "type": "macro_type_specifier",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "primitive_type", "type": "primitive_type",
"named": true "named": true
@ -2185,6 +2201,10 @@
"type": "module_import", "type": "module_import",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "preproc_def", "type": "preproc_def",
"named": true "named": true
@ -2408,77 +2428,7 @@
"named": true "named": true
}, },
{ {
"type": "primitive_type", "type": "ns_enum_specifier",
"named": true
},
{
"type": "sized_type_specifier",
"named": true
},
{
"type": "struct_specifier",
"named": true
},
{
"type": "type_identifier",
"named": true
},
{
"type": "typeof_specifier",
"named": true
},
{
"type": "union_specifier",
"named": true
}
]
},
"type": {
"multiple": false,
"required": false,
"types": [
{
"type": "BOOL",
"named": true
},
{
"type": "Class",
"named": true
},
{
"type": "IMP",
"named": true
},
{
"type": "SEL",
"named": true
},
{
"type": "atomic_specifier",
"named": true
},
{
"type": "auto",
"named": true
},
{
"type": "enum_specifier",
"named": true
},
{
"type": "generic_type_specifier",
"named": true
},
{
"type": "id",
"named": true
},
{
"type": "instancetype",
"named": true
},
{
"type": "macro_type_specifier",
"named": true "named": true
}, },
{ {
@ -2645,6 +2595,10 @@
"type": "macro_type_specifier", "type": "macro_type_specifier",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "primitive_type", "type": "primitive_type",
"named": true "named": true
@ -2865,6 +2819,10 @@
"type": "nonnull", "type": "nonnull",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "nullable", "type": "nullable",
"named": true "named": true
@ -2961,6 +2919,10 @@
"type": "macro_type_specifier", "type": "macro_type_specifier",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "primitive_type", "type": "primitive_type",
"named": true "named": true
@ -3173,6 +3135,10 @@
"type": "macro_type_specifier", "type": "macro_type_specifier",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "primitive_type", "type": "primitive_type",
"named": true "named": true
@ -3343,6 +3309,10 @@
"type": "macro_type_specifier", "type": "macro_type_specifier",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "primitive_type", "type": "primitive_type",
"named": true "named": true
@ -3693,6 +3663,10 @@
"type": "nonnull", "type": "nonnull",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "nullable", "type": "nullable",
"named": true "named": true
@ -3890,6 +3864,10 @@
"type": "macro_type_specifier", "type": "macro_type_specifier",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "primitive_type", "type": "primitive_type",
"named": true "named": true
@ -4030,6 +4008,10 @@
"type": "nonnull", "type": "nonnull",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "nullable", "type": "nullable",
"named": true "named": true
@ -4152,6 +4134,10 @@
"type": "macro_type_specifier", "type": "macro_type_specifier",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "primitive_type", "type": "primitive_type",
"named": true "named": true
@ -4302,6 +4288,10 @@
"type": "nonnull", "type": "nonnull",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "nullable", "type": "nullable",
"named": true "named": true
@ -4424,6 +4414,10 @@
"type": "macro_type_specifier", "type": "macro_type_specifier",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "primitive_type", "type": "primitive_type",
"named": true "named": true
@ -4560,6 +4554,110 @@
"named": true, "named": true,
"fields": {} "fields": {}
}, },
{
"type": "ns_enum_specifier",
"named": true,
"fields": {
"body": {
"multiple": false,
"required": false,
"types": [
{
"type": "enumerator_list",
"named": true
}
]
},
"name": {
"multiple": false,
"required": false,
"types": [
{
"type": "type_identifier",
"named": true
}
]
},
"type": {
"multiple": false,
"required": true,
"types": [
{
"type": "BOOL",
"named": true
},
{
"type": "Class",
"named": true
},
{
"type": "IMP",
"named": true
},
{
"type": "SEL",
"named": true
},
{
"type": "atomic_specifier",
"named": true
},
{
"type": "auto",
"named": true
},
{
"type": "enum_specifier",
"named": true
},
{
"type": "generic_type_specifier",
"named": true
},
{
"type": "id",
"named": true
},
{
"type": "instancetype",
"named": true
},
{
"type": "macro_type_specifier",
"named": true
},
{
"type": "ns_enum_specifier",
"named": true
},
{
"type": "primitive_type",
"named": true
},
{
"type": "sized_type_specifier",
"named": true
},
{
"type": "struct_specifier",
"named": true
},
{
"type": "type_identifier",
"named": true
},
{
"type": "typeof_specifier",
"named": true
},
{
"type": "union_specifier",
"named": true
}
]
}
}
},
{ {
"type": "number_expression", "type": "number_expression",
"named": true, "named": true,
@ -4646,6 +4744,10 @@
"type": "macro_type_specifier", "type": "macro_type_specifier",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "primitive_type", "type": "primitive_type",
"named": true "named": true
@ -5122,6 +5224,10 @@
"type": "module_import", "type": "module_import",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "preproc_call", "type": "preproc_call",
"named": true "named": true
@ -5289,6 +5395,10 @@
"type": "module_import", "type": "module_import",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "preproc_call", "type": "preproc_call",
"named": true "named": true
@ -5573,6 +5683,10 @@
"type": "module_import", "type": "module_import",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "preproc_call", "type": "preproc_call",
"named": true "named": true
@ -5765,6 +5879,10 @@
"type": "module_import", "type": "module_import",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "preproc_call", "type": "preproc_call",
"named": true "named": true
@ -6048,6 +6166,10 @@
"type": "macro_type_specifier", "type": "macro_type_specifier",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "primitive_type", "type": "primitive_type",
"named": true "named": true
@ -6173,6 +6295,10 @@
"type": "method_declaration", "type": "method_declaration",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "optional", "type": "optional",
"named": true "named": true
@ -6405,7 +6531,7 @@
}, },
{ {
"type": "string_literal", "type": "string_literal",
"named": false, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
@ -6635,6 +6761,10 @@
"type": "macro_type_specifier", "type": "macro_type_specifier",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "primitive_type", "type": "primitive_type",
"named": true "named": true
@ -6871,6 +7001,10 @@
"type": "module_import", "type": "module_import",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "preproc_def", "type": "preproc_def",
"named": true "named": true
@ -7000,6 +7134,10 @@
"multiple": false, "multiple": false,
"required": false, "required": false,
"types": [ "types": [
{
"type": "attribute_specifier",
"named": true
},
{ {
"type": "identifier", "type": "identifier",
"named": true "named": true
@ -7064,6 +7202,10 @@
"type": "macro_type_specifier", "type": "macro_type_specifier",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "primitive_type", "type": "primitive_type",
"named": true "named": true
@ -7172,6 +7314,10 @@
"type": "macro_type_specifier", "type": "macro_type_specifier",
"named": true "named": true
}, },
{
"type": "ns_enum_specifier",
"named": true
},
{ {
"type": "primitive_type", "type": "primitive_type",
"named": true "named": true
@ -8239,11 +8385,11 @@
}, },
{ {
"type": "number_literal", "type": "number_literal",
"named": true "named": false
}, },
{ {
"type": "number_literal", "type": "number_literal",
"named": false "named": true
}, },
{ {
"type": "oneway", "type": "oneway",

1029050
src/parser.c

File diff suppressed because it is too large Load Diff

View File

@ -825,7 +825,7 @@ Blocks: as a instance variable
parameters: (parameter_list))))) parameters: (parameter_list)))))
================================================================================ ================================================================================
Blocks: unknown [FIXME] Blocks: unknown
================================================================================ ================================================================================
extern void use(id); extern void use(id);

View File

@ -611,7 +611,7 @@ typedef void (^AFURLSessionTaskDidFinishCollectingMetricsBlock)(NSURLSession *se
type: (type_identifier) type: (type_identifier)
declarator: (pointer_declarator declarator: (pointer_declarator
declarator: (identifier))))) declarator: (identifier)))))
(attribute_specifier attributes: (attribute_specifier
(availability_attribute_specifier))) (availability_attribute_specifier)))
(type_definition (type_definition
type: (primitive_type) type: (primitive_type)
@ -630,7 +630,7 @@ typedef void (^AFURLSessionTaskDidFinishCollectingMetricsBlock)(NSURLSession *se
type: (type_identifier) type: (type_identifier)
declarator: (pointer_declarator declarator: (pointer_declarator
declarator: (identifier))))) declarator: (identifier)))))
(attribute_specifier attributes: (attribute_specifier
(availability_attribute_specifier (availability_attribute_specifier
(platform_version (platform_version
platform: (platform) platform: (platform)

View File

@ -45,7 +45,7 @@ typedef NS_ENUM(NSUInteger, RLMSyncStopPolicy);
declarator: (identifier) declarator: (identifier)
(swift_name_attribute_sepcifier))) (swift_name_attribute_sepcifier)))
(type_definition (type_definition
type: (enum_specifier type: (ns_enum_specifier
type: (type_identifier) type: (type_identifier)
name: (type_identifier))) name: (type_identifier)))
(class_forward_declaration (class_forward_declaration
@ -75,7 +75,7 @@ typedef void (^JSONObjectBlock)(id json, JSONModelError *err) DEPRECATED_ATTRIBU
type: (type_identifier) type: (type_identifier)
declarator: (pointer_declarator declarator: (pointer_declarator
declarator: (identifier))))) declarator: (identifier)))))
(attribute_specifier attributes: (attribute_specifier
(availability_attribute_specifier)))) (availability_attribute_specifier))))
================================================================================ ================================================================================
@ -209,7 +209,7 @@ typedef void (^AFURLSessionTaskDidFinishCollectingMetricsBlock)(NSURLSession *se
type: (type_identifier) type: (type_identifier)
declarator: (pointer_declarator declarator: (pointer_declarator
declarator: (identifier))))) declarator: (identifier)))))
(attribute_specifier attributes: (attribute_specifier
(availability_attribute_specifier (availability_attribute_specifier
(platform_version (platform_version
platform: (platform) platform: (platform)
@ -354,7 +354,7 @@ typedef NS_ENUM(NSInteger, SVProgressHUDStyle) {
(translation_unit (translation_unit
(type_definition (type_definition
type: (enum_specifier type: (ns_enum_specifier
type: (type_identifier) type: (type_identifier)
name: (type_identifier) name: (type_identifier)
body: (enumerator_list body: (enumerator_list
@ -1021,7 +1021,7 @@ __auto_type copy = (typeof(self.message))[self.message copy];
arguments: (argument_list arguments: (argument_list
(string_literal))))) (string_literal)))))
type: (type_identifier) type: (type_identifier)
attributes: (identifier)) declarator: (type_identifier))
(declaration (declaration
type: (auto) type: (auto)
declarator: (init_declarator declarator: (init_declarator
@ -1371,7 +1371,7 @@ NS_ENUM(NSInteger)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
(translation_unit (translation_unit
(enum_specifier (ns_enum_specifier
type: (type_identifier) type: (type_identifier)
body: (enumerator_list body: (enumerator_list
(enumerator (enumerator

View File

@ -21,7 +21,7 @@ typedef SEL _Nonnull nonnull_SEL;
class_name: (id) class_name: (id)
type_reference: (protocol_qualifiers type_reference: (protocol_qualifiers
name: (identifier))) name: (identifier)))
attributes: (identifier)) declarator: (type_identifier))
(type_definition (type_definition
type: (generic_type_specifier type: (generic_type_specifier
class_name: (type_identifier) class_name: (type_identifier)
@ -31,7 +31,7 @@ typedef SEL _Nonnull nonnull_SEL;
declarator: (abstract_pointer_declarator)) declarator: (abstract_pointer_declarator))
(type_descriptor (type_descriptor
type: (id)))) type: (id))))
attributes: (identifier)) declarator: (type_identifier))
(type_definition (type_definition
type: (generic_type_specifier type: (generic_type_specifier
class_name: (type_identifier) class_name: (type_identifier)
@ -42,15 +42,15 @@ typedef SEL _Nonnull nonnull_SEL;
(type_descriptor (type_descriptor
type: (type_identifier) type: (type_identifier)
declarator: (abstract_pointer_declarator)))) declarator: (abstract_pointer_declarator))))
attributes: (identifier)) declarator: (type_identifier))
(type_definition (type_definition
type: (id) type: (id)
(type_qualifier) (type_qualifier)
attributes: (identifier)) declarator: (type_identifier))
(type_definition (type_definition
type: (SEL) type: (SEL)
(type_qualifier) (type_qualifier)
attributes: (identifier))) declarator: (type_identifier)))
================================================================================ ================================================================================
Typedef: attributes Typedef: attributes
@ -104,7 +104,7 @@ typedef __attribute__((__ext_vector_type__(2))) float vector_float2;
arguments: (argument_list arguments: (argument_list
(string_literal))))) (string_literal)))))
type: (type_identifier) type: (type_identifier)
attributes: (identifier)) declarator: (type_identifier))
(type_definition (type_definition
(attribute_specifier (attribute_specifier
(argument_list (argument_list
@ -113,7 +113,7 @@ typedef __attribute__((__ext_vector_type__(2))) float vector_float2;
arguments: (argument_list arguments: (argument_list
(number_literal))))) (number_literal)))))
type: (primitive_type) type: (primitive_type)
attributes: (identifier))) declarator: (type_identifier)))
================================================================================ ================================================================================
Typedef: struct Typedef: struct
@ -140,7 +140,7 @@ typedef struct __attribute__((objc_boxable)) _NSRange {
(field_declaration (field_declaration
type: (type_identifier) type: (type_identifier)
declarator: (field_identifier)))) declarator: (field_identifier))))
attributes: (identifier))) declarator: (type_identifier)))
================================================================================ ================================================================================
Typedef: struct Typedef: struct
@ -210,7 +210,7 @@ typedef struct {
(field_declaration (field_declaration
type: (type_identifier) type: (type_identifier)
declarator: (field_identifier)))) declarator: (field_identifier))))
attributes: (identifier)))) declarator: (type_identifier))))
================================================================================ ================================================================================
Typedef: block Typedef: block
@ -249,7 +249,7 @@ typedef void (^JSONObjectBlock)(id json, JSONModelError *err) DEPRECATED_ATTRIBU
type: (type_identifier) type: (type_identifier)
declarator: (pointer_declarator declarator: (pointer_declarator
declarator: (identifier))))) declarator: (identifier)))))
(attribute_specifier attributes: (attribute_specifier
(availability_attribute_specifier (availability_attribute_specifier
(platform_version (platform_version
platform: (platform) platform: (platform)
@ -275,7 +275,7 @@ typedef void (^JSONObjectBlock)(id json, JSONModelError *err) DEPRECATED_ATTRIBU
type: (type_identifier) type: (type_identifier)
declarator: (pointer_declarator declarator: (pointer_declarator
declarator: (identifier))))) declarator: (identifier)))))
(attribute_specifier attributes: (attribute_specifier
(availability_attribute_specifier)))) (availability_attribute_specifier))))
================================================================================ ================================================================================
@ -313,6 +313,114 @@ typedef void (*mtl_failedMethodCallback)(Class, Method);
(parameter_declaration (parameter_declaration
type: (type_identifier)))))) type: (type_identifier))))))
================================================================================
Typedef: enum
================================================================================
enum {
UITableViewCellStyleDefault,
UITableViewCellStyleValue1,
UITableViewCellStyleValue2,
UITableViewCellStyleSubtitle
};
typedef enum {
UITableViewCellStyleDefault,
UITableViewCellStyleValue1,
UITableViewCellStyleValue2,
UITableViewCellStyleSubtitle
} UITableViewCellStyle;
typedef enum {
UITableViewCellStyleDefault,
UITableViewCellStyleValue1,
UITableViewCellStyleValue2,
UITableViewCellStyleSubtitle
};
typedef NSInteger UITableViewCellStyle;
// enum attr-spec-seq(optional) identifier(optional) { enumerator-list }
enum week{Mon, Tue, Wed}; // type specifier
enum week day; // declaration, "day" is the declarator
// Every declaration of an enum or a typedef is a definition.
enum week{Mon, Tue, Wed}day; // declaring an enum variable
// "week{Mon, Tue, Wed}" is the type specifier
// "day" is the declarator
--------------------------------------------------------------------------------
(translation_unit
(enum_specifier
body: (enumerator_list
(enumerator
name: (identifier))
(enumerator
name: (identifier))
(enumerator
name: (identifier))
(enumerator
name: (identifier))))
(type_definition
type: (enum_specifier
body: (enumerator_list
(enumerator
name: (identifier))
(enumerator
name: (identifier))
(enumerator
name: (identifier))
(enumerator
name: (identifier))))
declarator: (type_identifier))
(type_definition
type: (enum_specifier
body: (enumerator_list
(enumerator
name: (identifier))
(enumerator
name: (identifier))
(enumerator
name: (identifier))
(enumerator
name: (identifier))))
declarator: (MISSING type_identifier))
(type_definition
type: (type_identifier)
declarator: (type_identifier))
(comment)
(enum_specifier
name: (type_identifier)
body: (enumerator_list
(enumerator
name: (identifier))
(enumerator
name: (identifier))
(enumerator
name: (identifier))))
(comment)
(declaration
type: (enum_specifier
name: (type_identifier))
declarator: (identifier))
(comment)
(comment)
(declaration
type: (enum_specifier
name: (type_identifier)
body: (enumerator_list
(enumerator
name: (identifier))
(enumerator
name: (identifier))
(enumerator
name: (identifier))))
declarator: (identifier))
(comment)
(comment)
(comment))
================================================================================ ================================================================================
Typedef: NS_ENUM Typedef: NS_ENUM
================================================================================ ================================================================================
@ -356,11 +464,11 @@ typedef enum AvatarStyle : NSUInteger {
(translation_unit (translation_unit
(type_definition (type_definition
type: (enum_specifier type: (ns_enum_specifier
type: (type_identifier) type: (type_identifier)
name: (type_identifier))) name: (type_identifier)))
(type_definition (type_definition
type: (enum_specifier type: (ns_enum_specifier
type: (type_identifier) type: (type_identifier)
name: (type_identifier) name: (type_identifier)
body: (enumerator_list body: (enumerator_list
@ -378,7 +486,7 @@ typedef enum AvatarStyle : NSUInteger {
(enumerator (enumerator
name: (identifier))))) name: (identifier)))))
(type_definition (type_definition
type: (enum_specifier type: (ns_enum_specifier
type: (type_identifier) type: (type_identifier)
name: (type_identifier) name: (type_identifier)
body: (enumerator_list body: (enumerator_list
@ -394,7 +502,7 @@ typedef enum AvatarStyle : NSUInteger {
value: (number_literal)) value: (number_literal))
(enumerator (enumerator
name: (identifier)))) name: (identifier))))
attributes: (identifier)) declarator: (type_identifier))
(type_definition (type_definition
type: (enum_specifier type: (enum_specifier
name: (type_identifier) name: (type_identifier)
@ -405,7 +513,7 @@ typedef enum AvatarStyle : NSUInteger {
value: (number_literal)) value: (number_literal))
(enumerator (enumerator
name: (identifier)))) name: (identifier))))
attributes: (identifier))) declarator: (type_identifier)))
================================================================================ ================================================================================
Typedef: NS_ENUM without typedef Typedef: NS_ENUM without typedef
@ -420,7 +528,7 @@ NS_ENUM(NSInteger)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
(translation_unit (translation_unit
(enum_specifier (ns_enum_specifier
type: (type_identifier) type: (type_identifier)
body: (enumerator_list body: (enumerator_list
(enumerator (enumerator
@ -446,7 +554,7 @@ typedef NS_ENUM(NSInteger, TTCameraDetectionType) {
(translation_unit (translation_unit
(type_definition (type_definition
type: (enum_specifier type: (ns_enum_specifier
type: (type_identifier) type: (type_identifier)
name: (type_identifier) name: (type_identifier)
body: (enumerator_list body: (enumerator_list
@ -498,7 +606,7 @@ typedef NS_ENUM(NSInteger, SVProgressHUDStyle) {
(translation_unit (translation_unit
(type_definition (type_definition
type: (enum_specifier type: (ns_enum_specifier
type: (type_identifier) type: (type_identifier)
name: (type_identifier) name: (type_identifier)
body: (enumerator_list body: (enumerator_list
@ -534,7 +642,7 @@ typedef NS_OPTIONS(NSUInteger, ActionType) {
(translation_unit (translation_unit
(type_definition (type_definition
type: (enum_specifier type: (ns_enum_specifier
type: (type_identifier) type: (type_identifier)
name: (type_identifier) name: (type_identifier)
body: (enumerator_list body: (enumerator_list

View File

@ -457,14 +457,14 @@ Struct
struct unarchive_list { struct unarchive_list {
int ifield; int ifield;
id *list; id *list;
}; // FIXME };
@end @end
struct type_s { struct type_s {
SS may_recurse; SS may_recurse;
id id_val; id id_val;
}; }; // FIXME
struct Derived : type_s { }; struct Derived : type_s { };
@ -484,8 +484,7 @@ struct Derived : type_s { };
type: (id) type: (id)
declarator: (pointer_declarator declarator: (pointer_declarator
declarator: (field_identifier))))) declarator: (field_identifier)))))
declarator: (MISSING identifier)) declarator: (MISSING identifier)))
(comment))
(struct_specifier (struct_specifier
name: (type_identifier) name: (type_identifier)
body: (field_declaration_list body: (field_declaration_list
@ -495,6 +494,7 @@ struct Derived : type_s { };
(field_declaration (field_declaration
type: (id) type: (id)
declarator: (field_identifier)))) declarator: (field_identifier))))
(comment)
(struct_specifier (struct_specifier
name: (type_identifier) name: (type_identifier)
(superclass_reference (superclass_reference