/[pcre]/code/trunk/maint/GenerateUtt.py
ViewVC logotype

Contents of /code/trunk/maint/GenerateUtt.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 351 - (show annotations)
Fri Jul 4 18:27:16 2008 UTC (11 years, 6 months ago) by ph10
File MIME type: text/x-python
File size: 2404 byte(s)
Error occurred while calculating annotation data.
Final tidies for new Unicode property code; upgrade to Unicode 5.1.0.
1 #! /usr/bin/python
2
3 # Generate utt tables.
4
5 # The source file pcre_tables.c contains (amongst other things), a table that
6 # is indexed by script name. In order to reduce the number of relocations when
7 # loading the library, the names are held as a single large string, with
8 # offsets in the table. This is tedious to maintain by hand. Therefore, this
9 # script is used to generate the table. The output is sent to stdout.
10
11 script_names = ['Arabic', 'Armenian', 'Bengali', 'Bopomofo', 'Braille', 'Buginese', 'Buhid', 'Canadian_Aboriginal', \
12 'Cherokee', 'Common', 'Coptic', 'Cypriot', 'Cyrillic', 'Deseret', 'Devanagari', 'Ethiopic', 'Georgian', \
13 'Glagolitic', 'Gothic', 'Greek', 'Gujarati', 'Gurmukhi', 'Han', 'Hangul', 'Hanunoo', 'Hebrew', 'Hiragana', \
14 'Inherited', 'Kannada', 'Katakana', 'Kharoshthi', 'Khmer', 'Lao', 'Latin', 'Limbu', 'Linear_B', 'Malayalam', \
15 'Mongolian', 'Myanmar', 'New_Tai_Lue', 'Ogham', 'Old_Italic', 'Old_Persian', 'Oriya', 'Osmanya', 'Runic', \
16 'Shavian', 'Sinhala', 'Syloti_Nagri', 'Syriac', 'Tagalog', 'Tagbanwa', 'Tai_Le', 'Tamil', 'Telugu', 'Thaana', \
17 'Thai', 'Tibetan', 'Tifinagh', 'Ugaritic', 'Yi', \
18 # New for Unicode 5.0
19 'Balinese', 'Cuneiform', 'Nko', 'Phags_Pa', 'Phoenician', \
20 # New for Unicode 5.1
21 'Carian', 'Cham', 'Kayah_Li', 'Lepcha', 'Lycian', 'Lydian', 'Ol_Chiki', 'Rejang', 'Saurashtra', 'Sundanese', 'Vai'
22 ]
23
24 category_names = ['Cc', 'Cf', 'Cn', 'Co', 'Cs', 'Ll', 'Lm', 'Lo', 'Lt', 'Lu',
25 'Mc', 'Me', 'Mn', 'Nd', 'Nl', 'No', 'Pc', 'Pd', 'Pe', 'Pf', 'Pi', 'Po', 'Ps',
26 'Sc', 'Sk', 'Sm', 'So', 'Zl', 'Zp', 'Zs' ]
27
28 general_category_names = ['C', 'L', 'M', 'N', 'P', 'S', 'Z']
29
30 utt_table = zip(script_names, ['PT_SC'] * len(script_names))
31 utt_table += zip(category_names, ['PT_PC'] * len(category_names))
32 utt_table += zip(general_category_names, ['PT_GC'] * len(general_category_names))
33 utt_table.append(('L&', 'PT_LAMP'))
34 utt_table.append(('Any', 'PT_ANY'))
35
36 utt_table.sort()
37
38 print 'const char _pcre_utt_names[] = ';
39 last = ''
40 for utt in utt_table:
41 if utt == utt_table[-1]:
42 last = ';'
43 print ' "%s\\0"%s' % (utt[0], last)
44
45 print '\nconst ucp_type_table _pcre_utt[] = { '
46 offset = 0
47 last = ','
48 for utt in utt_table:
49 if utt[1] in ('PT_ANY', 'PT_LAMP'):
50 value = '0'
51 else:
52 value = 'ucp_' + utt[0]
53 if utt == utt_table[-1]:
54 last = ''
55 print ' { %3d, %s, %s }%s ' % (offset, utt[1], value, last)
56 offset += len(utt[0]) + 1
57 print '};'

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5