mirror of
https://github.com/lightning/bolts.git
synced 2025-03-09 15:52:43 +01:00
tools/extract-formats.py: handle continuous types in tlvs.
We were swallowing the unused line after `data`, but it's normal to do: ``` 1. tlvs: `n1` 2. types: 1. type: 1 (`tlv1`) 2. data: * [`tu64`:`amount_msat`] 1. type: 2 (`tlv2`) 2. data: * [`short_channel_id`:`scid`] ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
acad3fc8fe
commit
6af2ba23a8
1 changed files with 4 additions and 5 deletions
|
@ -97,13 +97,13 @@ def parse_type(genline, output, name, value, option, in_tlv=None):
|
||||||
|
|
||||||
# Expect a data: line before values, if any
|
# Expect a data: line before values, if any
|
||||||
if line.lstrip() != '2. data:':
|
if line.lstrip() != '2. data:':
|
||||||
return
|
return _, line
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
i, line = next(genline)
|
i, line = next(genline)
|
||||||
match = dataline.fullmatch(line)
|
match = dataline.fullmatch(line)
|
||||||
if not match:
|
if not match:
|
||||||
break
|
return _, line
|
||||||
|
|
||||||
if '*' in match.group('typefield'):
|
if '*' in match.group('typefield'):
|
||||||
num,typename = match.group('typefield').split('*')
|
num,typename = match.group('typefield').split('*')
|
||||||
|
@ -134,15 +134,14 @@ def parse_tlv(genline, output, name, option):
|
||||||
if line != '2. types:':
|
if line != '2. types:':
|
||||||
raise ValueError('{}: Expected "2. types:" line'.format(i))
|
raise ValueError('{}: Expected "2. types:" line'.format(i))
|
||||||
|
|
||||||
|
_, line = next(genline)
|
||||||
while True:
|
while True:
|
||||||
_, line = next(genline)
|
|
||||||
|
|
||||||
# Inside tlv, types are indented.
|
# Inside tlv, types are indented.
|
||||||
match = typeline.fullmatch(line.lstrip())
|
match = typeline.fullmatch(line.lstrip())
|
||||||
if not match:
|
if not match:
|
||||||
break
|
break
|
||||||
|
|
||||||
parse_type(genline, output, match.group('name'), match.group('value'), match.group('option'), name)
|
_, line = parse_type(genline, output, match.group('name'), match.group('value'), match.group('option'), name)
|
||||||
|
|
||||||
|
|
||||||
# 1. subtype: `input_info`
|
# 1. subtype: `input_info`
|
||||||
|
|
Loading…
Add table
Reference in a new issue