import re


def apply_lit_token(arg, macro):
    """Apply the LIT or ARG_LIT macro to a single token."""
    # The macro must only be applied to a floating-point constant, not
    # to an integer constant or lit_* value.
    sign_re = r'[+-]?'
    exp_re = r'([+-])?[0-9]+'
    suffix_re = r'[lLfF]?'
    dec_exp_re = r'[eE]' + exp_re
    hex_exp_re = r'[pP]' + exp_re
    dec_frac_re = r'(?:[0-9]*\.[0-9]+|[0-9]+\.)'
    hex_frac_re = r'(?:[0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.)'
    dec_int_re = r'[0-9]+'
    hex_int_re = r'[0-9a-fA-F]+'
    dec_cst_re = r'(?:%s(?:%s)?|%s%s)' % (dec_frac_re, dec_exp_re,
                                          dec_int_re, dec_exp_re)
    hex_cst_re = r'0[xX](?:%s|%s)%s' % (hex_frac_re, hex_int_re, hex_exp_re)
    fp_cst_re = r'(%s(?:%s|%s))%s\Z' % (sign_re, dec_cst_re, hex_cst_re,
                                        suffix_re)
    m = re.match(fp_cst_re, arg)
    if m:
        return '%s (%s)' % (macro, m.group(1))
    else:
        return arg