From 063f374393b7e3a86acee232ae828ba674e95839 Mon Sep 17 00:00:00 2001 From: Paul Vinciguerra Date: Tue, 2 Jul 2019 13:00:58 -0400 Subject: vppapigen: allow decimal number in NUM token Needed to set f64 default values. Type: feature Change-Id: Ic58ebc0d9d890bf0e7821894285e61a5bee13199 Signed-off-by: Paul Vinciguerra --- src/tools/vppapigen/vppapigen.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tools/vppapigen/vppapigen.py b/src/tools/vppapigen/vppapigen.py index 9c6b21ed48d..8ae991c9c95 100755 --- a/src/tools/vppapigen/vppapigen.py +++ b/src/tools/vppapigen/vppapigen.py @@ -77,9 +77,12 @@ class VPPAPILexer(object): t_ignore_LINE_COMMENT = '//.*' def t_NUM(self, t): - r'0[xX][0-9a-fA-F]+|-?\d+' + r'0[xX][0-9a-fA-F]+|-?\d+\.?\d*' base = 16 if t.value.startswith('0x') else 10 - t.value = int(t.value, base) + if '.' in t.value: + t.value = float(t.value) + else: + t.value = int(t.value, base) return t def t_ID(self, t): @@ -123,6 +126,7 @@ def crc_block_combine(block, crc): s = str(block).encode() return binascii.crc32(s, crc) & 0xffffffff + class Service(): def __init__(self, caller, reply, events=None, stream=False): self.caller = caller -- cgit 1.2.3-korg