Changeset 3931 for proto


Ignore:
Timestamp:
Jul 28, 2014, 8:28:36 AM (5 years ago)
Author:
cameron
Message:

Prettier output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/RE/doc/UTF8_class.py

    r3930 r3931  
    99#
    1010# Definitions for debugging/prototyping
    11 def ByteClassCompiler(lbyte): return "\\x%x" % lbyte
    12 def ByteRangeCompiler(lbyte, hbyte): return "[\\x%x-\\x%x]" % (lbyte, hbyte)
    13 def make_or(e1, e2): return "(%s | %s)" % (e1, e2)
    14 def make_and(e1, e2): return "(%s & %s)" % (e1, e2)
    15 def make_shift_forward(e, n): return "(%s >> %i)" % (e, n)
    16 def make_assign(v, e): return v + " := " + e + "\n"
    17 def make_if(p, s): return ["if %s\n" %p] + s + ["endif %s\n" %p]
     11def ByteClassCompiler(lbyte): return "ByteClass(%x)" % lbyte
     12def ByteRangeCompiler(lbyte, hbyte): return "ByteClass(%x,%x)" % (lbyte, hbyte)
     13def make_or(e1, e2): return "Or(%s, %s)" % (e1, e2)
     14def make_and(e1, e2): return "And(%s, %s)" % (e1, e2)
     15def make_shift_forward(e, n): return "Advance(%s,%i)" % (e, n)
     16def make_assign(v, e): return v + " = " + e + "\n"
     17def make_if(p, s): return ["if %s\n" %p] + ["  " + x for x in s] + ["endif %s\n" %p]
    1818#
    1919def utf8_length(codepoint):
     
    202202   generated_code = []
    203203   for k in charClassMap.keys():
    204      generated_code.append(make_assign(k, "0"))
     204     generated_code.append(make_assign("CC_" + k, "0"))
    205205   generated_code += generateCharClassDefsInIfHierarchy((0, 0x10FFFF), ifRangeList, charClassMap)
    206206   return generated_code
    207207
    208 (catlen, catdef) = parse_general()
    209 
    210 map1 = {}
    211 map1['Cc'] = catdef['Cc']
    212 ifr = [(0,0x7FF), (0, 0x7F), (0x80, 0x3FF), (0x400,0x7FF), (0x800, 0xFFFF), (0x10000, 0x10FFFF)]
    213 
     208(catlen, UnicodeCategoryMap) = parse_general()
     209defaultIfRangeList = [(0,0x7FF), (0, 0x7F), (0x80, 0x3FF), (0x400,0x7FF), (0x800, 0xFFFF), (0x10000, 0x10FFFF)]
     210def generateDefs1(general_category):
     211  catmap = {}
     212  catmap[general_category] = UnicodeCategoryMap[general_category]
     213  code = generateCharClassDefs(defaultIfRangeList, catmap)
     214  return "".join(code)
     215
     216
     217
Note: See TracChangeset for help on using the changeset viewer.