MCPcopy Create free account
hub / github.com/apache/qpid-proton / parse_item

Function parse_item

c/tools/codec-generator/generate.py:269–354  ·  view source on GitHub ↗
(format: str)

Source from the content-addressed store, hash-verified

267
268
269def parse_item(format: str) -> Tuple[ASTNode, str]:
270 if len(format) == 0:
271 return EmptyNode(), ''
272 if format.startswith('DL['):
273 l, rest = parse_list(format[3:])
274 b, rest = expect_char(rest, ']')
275 if not b:
276 raise ParseError(format)
277 return DescListNode(l), rest
278 elif format.startswith('D.['):
279 l, rest = parse_list(format[3:])
280 b, rest = expect_char(rest, ']')
281 if not b:
282 raise ParseError(format)
283 return DescListIgnoreTypeNode(l), rest
284 elif format.startswith('['):
285 l, rest = parse_list(format[1:])
286 b, rest = expect_char(rest, ']')
287 if not b:
288 raise ParseError(format)
289 return ListNode('list', l, []), rest
290 elif format.startswith('D?LR'):
291 return ASTNode('described_maybe_type_raw', ['bool', 'uint64_t', 'pn_bytes_t'], consume_types=['bool*', 'uint64_t*', 'pn_bytes_t*']), format[4:]
292 elif format.startswith('D?L?.'):
293 return ASTNode('described_maybe_type_maybe_anything', ['bool', 'uint64_t', 'bool'], consume_types=['bool*', 'uint64_t*', 'bool*']), format[4:]
294 elif format.startswith('DLC'):
295 return ASTNode('described_type_copy', ['uint64_t', 'pn_data_t*'], consume_types=['uint64_t*', 'pn_data_t*']), format[3:]
296 elif format.startswith('DLR'):
297 return ASTNode('described_type_raw', ['uint64_t', 'pn_bytes_t'], consume_types=['uint64_t*', 'pn_bytes_t*']), format[3:]
298 elif format.startswith('DL.'):
299 return ASTNode('described_type_anything', ['uint64_t']), format[3:]
300 elif format.startswith('D?L.'):
301 return ASTNode('described_maybe_type_anything', ['bool', 'uint64_t']), format[3:]
302 elif format.startswith('D..'):
303 return NullNode('described_anything'), format[3:]
304 elif format.startswith('D.C'):
305 return ASTNode('described_copy', ['pn_data_t*'], consume_types=['pn_data_t*']), format[3:]
306 elif format.startswith('D.R'):
307 return ASTNode('described_raw', ['pn_bytes_t'], consume_types=['pn_bytes_t*']), format[3:]
308 elif format.startswith('@T['):
309 l, rest = parse_list(format[3:])
310 b, rest = expect_char(rest, ']')
311 if not b:
312 raise ParseError(format)
313 return ArrayNode(l), rest
314 elif format.startswith('?'):
315 i, rest = parse_item(format[1:])
316 return OptionNode(i), rest
317 elif format.startswith('*s'):
318 return ASTNode('counted_symbols', ['size_t', 'char**']), format[2:]
319 elif format.startswith('.'):
320 return NullNode('anything'), format[1:]
321 elif format.startswith('s'):
322 return ASTNode('symbol', ['pn_bytes_t'], consume_types=['pn_bytes_t*']), format[1:]
323 elif format.startswith('S'):
324 return ASTNode('string', ['pn_bytes_t'], consume_types=['pn_bytes_t*']), format[1:]
325 elif format.startswith('c'):
326 return ASTNode('condition', ['pn_condition_t*'], consume_types=['pn_condition_t*']), format[1:]

Callers 3

parse_listFunction · 0.85
consume_functionFunction · 0.85
emit_functionFunction · 0.85

Calls 11

EmptyNodeClass · 0.85
parse_listFunction · 0.85
expect_charFunction · 0.85
ParseErrorClass · 0.85
DescListNodeClass · 0.85
ListNodeClass · 0.85
ASTNodeClass · 0.85
NullNodeClass · 0.85
ArrayNodeClass · 0.85
OptionNodeClass · 0.85

Tested by

no test coverage detected