[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] decodetree: Allow use of hex/bin format for argument field v
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH] decodetree: Allow use of hex/bin format for argument field values |
Date: |
Tue, 1 Dec 2020 09:47:55 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 |
On 11/30/20 7:22 PM, Richard Henderson wrote:
> On 11/30/20 6:26 AM, Philippe Mathieu-Daudé wrote:
>> # 'Foo=number' sets an argument field to a constant value
>> - if re.fullmatch(re_C_ident + '=[+-]?[0-9]+', t):
>> + if re.fullmatch(re_C_ident + '=[+-]?(0[bx])?[0-9]+', t):
>> (fname, value) = t.split('=')
>> - value = int(value)
>> + if re.fullmatch('[+-]?0b[0-9]+', value):
>> + base = 2
>> + elif re.fullmatch('[+-]?0x[0-9]+', value):
>> + base = 16
>> + else:
>> + base = 10
>> + value = int(value, base)
>> flds = add_field(lineno, flds, fname, ConstField(value))
>> continue
>
> Well, the regxps are off. No letters for the hex, and 9 accepted for binary.
> I think with the right regexps, just trusting int(value, 0) is good enough.
OK!
>
> So maybe something like
>
> re_C_ident + "=[+-]?([0-9]+|0x[0-9a-fA-F]+|0b[01]+)"
Better indeed :)
Thanks,
Phil.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH] decodetree: Allow use of hex/bin format for argument field values,
Philippe Mathieu-Daudé <=