(m, srcinfo, anon_name)
| 54 | |
| 55 | |
| 56 | def _parse_next(m, srcinfo, anon_name): |
| 57 | ( |
| 58 | empty, |
| 59 | # compound type decl (maybe inline) |
| 60 | compound_leading, compound_kind, compound_name, |
| 61 | forward_kind, forward_name, maybe_inline_actual, |
| 62 | # typedef |
| 63 | typedef_decl, typedef_func_params, |
| 64 | # vars and funcs |
| 65 | storage, func_inline, decl, |
| 66 | func_params, func_delim, func_legacy_params, |
| 67 | var_init, var_ending, |
| 68 | ) = m.groups() |
| 69 | remainder = srcinfo.text[m.end():] |
| 70 | |
| 71 | if empty: |
| 72 | log_match('global empty', m) |
| 73 | srcinfo.advance(remainder) |
| 74 | |
| 75 | elif maybe_inline_actual: |
| 76 | log_match('maybe_inline_actual', m) |
| 77 | # Ignore forward declarations. |
| 78 | # XXX Maybe return them too (with an "isforward" flag)? |
| 79 | if not maybe_inline_actual.strip().endswith(';'): |
| 80 | remainder = maybe_inline_actual + remainder |
| 81 | yield srcinfo.resolve(forward_kind, None, forward_name) |
| 82 | if maybe_inline_actual.strip().endswith('='): |
| 83 | # We use a dummy prefix for a fake typedef. |
| 84 | # XXX Ideally this case would not be caught by MAYBE_INLINE_ACTUAL. |
| 85 | _, name, data = parse_var_decl(f'{forward_kind} {forward_name} fake_typedef_{forward_name}') |
| 86 | yield srcinfo.resolve('typedef', data, name, parent=None) |
| 87 | remainder = f'{name} {remainder}' |
| 88 | srcinfo.advance(remainder) |
| 89 | |
| 90 | elif compound_kind: |
| 91 | kind = compound_kind |
| 92 | name = compound_name or anon_name('inline-') |
| 93 | # Immediately emit a forward declaration. |
| 94 | yield srcinfo.resolve(kind, name=name, data=None) |
| 95 | |
| 96 | # un-inline the decl. Note that it might not actually be inline. |
| 97 | # We handle the case in the "maybe_inline_actual" branch. |
| 98 | srcinfo.nest( |
| 99 | remainder, |
| 100 | f'{compound_leading or ""} {compound_kind} {name}', |
| 101 | ) |
| 102 | def parse_body(source): |
| 103 | _parse_body = DECL_BODY_PARSERS[compound_kind] |
| 104 | |
| 105 | data = [] # members |
| 106 | ident = f'{kind} {name}' |
| 107 | for item in _parse_body(source, anon_name, ident): |
| 108 | if item.kind == 'field': |
| 109 | data.append(item) |
| 110 | else: |
| 111 | yield item |
| 112 | # XXX Should "parent" really be None for inline type decls? |
| 113 | yield srcinfo.resolve(kind, data, name, parent=None) |
no test coverage detected
searching dependent graphs…