Changeset 2232 for proto


Ignore:
Timestamp:
Jul 3, 2012, 3:17:39 PM (7 years ago)
Author:
cameron
Message:

Transcode compiler generates charset_compiler input

Location:
proto/charsetcompiler
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • proto/charsetcompiler/charset_compiler.py

    r2229 r2232  
    367367
    368368def charset_expr(chardef):
     369    if chardef.items == []: return FalseLiteral()
    369370    e1 = char_or_range_expr(chardef.items[0])
    370371    for i in range(1, len(chardef.items)):
  • proto/charsetcompiler/charset_input_parser.py

    r915 r2232  
    2525        """
    2626        if len(statement)==0:
    27             return
     27            return []
    2828       
    2929        tokens_tuple = statement.partition('=')
  • proto/charsetcompiler/transcode_compiler.py

    r2229 r2232  
    2626#
    2727
    28 import codecs
     28import codecs, sys, string
    2929#
    3030#
     
    7373        return items
    7474
     75def WriteLegacy_8bit_CharDefs(charset_name, f):
     76        defs = "# %s to UTF-16 decoding equations\n" % charset_name
     77        t = Legacy_8bit_To_UCS2_Table(charset_name)
     78        for bit in range(0, 8):
     79                cs = UCS2_Table_To_u16hi_bit(t, bit)
     80                defs += "u16hi_bit_%i = [%s]\n" % (bit, string.join(cs, "").encode('string-escape'))
     81        for bit in range(0, 8):
     82                cs = UCS2_Table_To_u16lo_bit(t, bit)
     83                defs += "x16lo_bit_%i = [%s]\n" % (bit, string.join(cs, "").encode('string-escape'))
     84        f.write(defs)
     85
     86if __name__ == "__main__":
     87        args = sys.argv[1:]
     88        if len(args) == 1:
     89                WriteLegacy_8bit_CharDefs(args[0], sys.stdout)
     90        elif len(args) == 2:
     91                f = open(args[1], "w")
     92                WriteLegacy_8bit_CharDefs(args[0], f)
     93                f.close()
    7594
    7695
Note: See TracChangeset for help on using the changeset viewer.