def t_approx_2(t): # All decimal forms without a '.': r'''[0-9]+ (?: (?: ~[0-9] )? [eE] [+-]?[0-9]+ | ~[0-9] ) (?=[[(:]?[]) \r\n]) # followed by ], ), space or newline ''' t.value = number.approx(t.value).int_exp() t.type = 'APPROX_NUMBER' return t
def t_APPROX_NUMBER(t): # All decimal forms with a '.': r'''(?: [0-9]+ \.[0-9]* | \.[0-9]+ ) (?: ~[0-9] )? (?: [eE] [+-]?[0-9]+ )? (?=[[(:]?[]) \r\n]) # followed by ], ), space or newline ''' t.value = number.approx(t.value).int_exp() return t
def t_hex_approx_2(t): # All hex forms without a '.': r'''0[xX] [0-9a-fA-F]+ (?: (?: ~[0-9a-fA-F] )? [xX] [+-]?[0-9]+ | ~[0-9a-fA-F] ) (?=[[(:]?[]) \r\n]) # followed by ], ), space or newline ''' t.value = number.approx(t.value).int_exp() t.type = 'APPROX_NUMBER' return t
def t_hex_APPROX_NUMBER(t): # All hex forms with a '.': r'''0[xX] (?: [0-9a-fA-F]+ \.[0-9a-fA-F]* | \.[0-9a-fA-F]+ ) (?: ~[0-9a-fA-F] )? (?: [xX] [+-]?[0-9]+ )? (?=[[(:]?[]) \r\n]) # followed by ], ), space or newline ''' t.value = number.approx(t.value).int_exp() t.type = 'APPROX_NUMBER' return t