@@ -246,7 +246,7 @@ def t_CHAR(self, t):
246246 return t
247247
248248 def t_HEXA (self , t ):
249- r'([0-9][0-9a-fA-F]*[hH])|(\$[0-9a-fA-F]+) |(0x[0-9a-fA-F]+ )'
249+ r'([0-9](_? [0-9a-fA-F]) *[hH])|(\$[0-9a-fA-F](_?[0-9a-fA-F])*) |(0x[0-9a-fA-F](_?[0-9a-dA-F])* )'
250250
251251 if t .value [:2 ] == '0x' :
252252 t .value = t .value [2 :] # Remove initial 0x
@@ -255,22 +255,22 @@ def t_HEXA(self, t):
255255 else :
256256 t .value = t .value [:- 1 ] # Remove last 'h'
257257
258- t .value = int (t .value , 16 ) # Convert to decimal
258+ t .value = int (t .value . replace ( '_' , '' ) , 16 ) # Convert to decimal
259259 t .type = 'INTEGER'
260260 return t
261261
262262 def t_BIN (self , t ):
263- r'(%[01]+)|( [01]+ [bB])' # A Binary integer
263+ r'(%[01](_? [01])*)|(0 [bB](_?[01])+ )' # A Binary integer
264264 # Note 00B is a 0 binary, but
265265 # 00Bh is a 12 in hex. So this pattern must come
266266 # after HEXA
267267
268268 if t .value [0 ] == '%' :
269269 t .value = t .value [1 :] # Remove initial %
270270 else :
271- t .value = t .value [: - 1 ] # Remove last 'b'
271+ t .value = t .value [2 : ] # Remove last 'b'
272272
273- t .value = int (t .value , 2 ) # Convert to decimal
273+ t .value = int (t .value . replace ( '_' , '' ) , 2 ) # Convert to decimal
274274 t .type = 'INTEGER'
275275 return t
276276
@@ -281,8 +281,8 @@ def t_INITIAL_TMPLABEL(self, t):
281281 return t
282282
283283 def t_INITIAL_preproc_INTEGER (self , t ):
284- r'[0-9]+ ' # an integer decimal number
285- t .value = int (t .value )
284+ r'[0-9](_?\d)* ' # an integer decimal number
285+ t .value = int (t .value . replace ( '_' , '' ) )
286286 return t
287287
288288 def t_INITIAL_ID (self , t ):
0 commit comments