vapi: add python scripts to vpp-dev package
[vpp.git] / src / tools / vppapigen / vppapigen.py
index fd87b18..8ae991c 100755 (executable)
@@ -23,8 +23,6 @@ global_types = {}
 def global_type_add(name, obj):
     '''Add new type to the dictionary of types '''
     type_name = 'vl_api_' + name + '_t'
-    if type_name in global_types:
-        raise KeyError('Type is already defined: {}'.format(name))
     global_types[type_name] = obj
 
 
@@ -79,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):
@@ -125,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