Exemplo n.º 1
0
def print_c_form(table):
    count = 0
    for slot, type, upright, code in table:
        count += 1
    print 'static const unsigned long nglyph = %d;' % count
    print 'static const char *glyph_control_sequence[nglyph] = {'
    for slot, type, upright, code in table:
        print '    "' + maputil.escape_c_form(code) + '",'
    print '};'
    print
    print 'static const unsigned int glyph_type[nglyph] = {'
    for slot, type, upright, code in table:
        if type == 'Alpha':
            type = 'Ord'
        if type != '-':
            print '    atom_t::TYPE_' + type.upper() + ','
        else:
            print '    atom_t::TYPE_ORD,'
    print '};'
    print
    print 'static const bool glyph_upright[nglyph] = {'
    for slot, type, upright, code in table:
        if type != '-':
            if upright != '0':
                print '    true,'
            else:
                print '    false,'
        else:
            print '    true,'
    print '};'
    print
    print 'static const wchar_t glyph_code_point[nglyph] = {'
    for slot, type, upright, code in table:
        print '    ' + maputil.ucs_c_form(slot) + ','
    print '};'
Exemplo n.º 2
0
def print_c_form(table):
    count = 0
    for slot, type, upright, code in table:
        count += 1
    print 'static const unsigned long nglyph = %d;' % count
    print 'static const char *glyph_control_sequence[nglyph] = {'
    for slot, type, upright, code in table:
        print '    "' + maputil.escape_c_form(code) + '",'
    print '};'
    print
    print 'static const unsigned int glyph_type[nglyph] = {'
    for slot, type, upright, code in table:
        if type == 'Alpha':
            type = 'Ord'
        if type != '-':
            print '    atom_t::TYPE_' + type.upper() + ','
        else:
            print '    atom_t::TYPE_ORD,'
    print '};'
    print
    print 'static const bool glyph_upright[nglyph] = {'
    for slot, type, upright, code in table:
        if type != '-':
            if upright != '0':
                print '    true,'
            else:
                print '    false,'
        else:
            print '    true,'
    print '};'
    print
    print 'static const wchar_t glyph_code_point[nglyph] = {'
    for slot, type, upright, code in table:
        print '    ' + maputil.ucs_c_form(slot) + ','
    print '};'
Exemplo n.º 3
0
def format_math_alpha(name, code):
    int_code = int(code, 16)
    if int_code < 65536:
        line = 'case \'%s\': _glyph = %s; break;' % \
               (maputil.escape_c_form(name),
                maputil.ucs_c_form(code))
    elif name.isupper():
        line = '_glyph = %s + (_code[0] - \'A\');' % \
               maputil.ucs_c_form(int_code -
                                  (ord(name[0]) - ord('A')))
    elif name.islower():
        line = '_glyph = %s + (_code[0] - \'a\');' % \
               maputil.ucs_c_form(int_code -
                                  (ord(name[0]) - ord('a')))
    elif name.isdigit():
        line = '_glyph = %s + (_code[0] - \'0\');' % \
               maputil.ucs_c_form(int_code -
                                  (ord(name[0]) - ord('0')))
    else:
        line = '(unhandled Unicode glyph %s)' % code
    return line
Exemplo n.º 4
0
        table.append([code.replace('intop', 'int'), [True, slot, None, True]])
for let_to in text_operator_table.keys():
    table.append([let_to, text_operator_table[let_to]])
table.sort(lambda u, v: cmp(u, v))

print 'static const unsigned long __noperator = %d;' % len(table)
print 'static const char *__operator_name[__noperator] = {'
for operator, list in table:
    print '    "' + operator.replace('\\', '\\\\') + '",'
print '};'
print
print 'static const wchar_t __operator_code_point[__noperator] = {'
for operator, list in table:
    symbol, code, text, nolimits = list
    if symbol:
        print '    ' + maputil.ucs_c_form(code) + ','
    else:
        print '    ' + maputil.ucs_c_form(0) + ','
print '};'
print
print 'static const char *__operator_control_sequence[__noperator] = {'
for operator, list in table:
    symbol, code, text, nolimits = list
    if symbol:
        print '    "",'
    else:
        print '    "' + text.replace('\\', '\\\\') + '",'
print '};'
print
print 'static const bool __operator_nolimits[__noperator] = {'
for operator, list in table:
Exemplo n.º 5
0
                      [True, slot, None, True]])
for let_to in text_operator_table.keys():
    table.append([let_to, text_operator_table[let_to]])
table.sort(lambda u, v: cmp(u, v))

print 'static const unsigned long __noperator = %d;' % len(table)
print 'static const char *__operator_name[__noperator] = {'
for operator, list in table:
    print '    "' + operator.replace('\\', '\\\\') + '",'
print '};'
print
print 'static const wchar_t __operator_code_point[__noperator] = {'
for operator, list in table:
    symbol, code, text, nolimits = list
    if symbol:
        print '    ' + maputil.ucs_c_form(code) + ','
    else:
        print '    ' + maputil.ucs_c_form(0) + ','
print '};'
print
print 'static const char *__operator_control_sequence[__noperator] = {'
for operator, list in table:
    symbol, code, text, nolimits = list
    if symbol:
        print '    "",'
    else:
        print '    "' + text.replace('\\', '\\\\') + '",'
print '};'
print
print 'static const bool __operator_nolimits[__noperator] = {'
for operator, list in table: