Changeset 5661 for icGREP/icgrep-devel


Ignore:
Timestamp:
Oct 2, 2017, 1:38:18 PM (20 months ago)
Author:
cameron
Message:

Multicolumn parsing support for UCD files - adding bpt property

Location:
icGREP/icgrep-devel
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/UCD-scripts/UCD_parser.py

    r5658 r5661  
    232232    property_object.finalizeProperty()
    233233
     234def parse_multicolumn_property_data(pfile, property_object_map, property_lookup_map, prop_code_list):
     235    f = open(UCD_config.UCD_src_dir + "/" + pfile)
     236    props = []
     237    lines = f.readlines()
     238    for t in lines:
     239        if UCD_skip.match(t):
     240            continue
     241        else:
     242            (cp_lo, cp_hi, fields) = parse_data_record(t)
     243            if len(fields) != len(prop_code_list): raise Exception("Mutlicolumn field count mismatch, expecting %i: " % len(prop_code_list) + t)
     244            for i in range(len(fields)):
     245                if fields[i] != '':
     246                    property_object_map[prop_code_list[i]].addDataRecord(cp_lo, cp_hi, fields[i])
     247    for p in prop_code_list:
     248        property_object_map[p].finalizeProperty()
     249
    234250def parse_ScriptExtensions_txt(script_property_object):
    235251    filename_root = 'ScriptExtensions'
  • icGREP/icgrep-devel/UCD-scripts/UCD_properties.py

    r5658 r5661  
    200200        self.property_data_headers.append(basename)
    201201
     202    def generate_multicolumn_properties_file(self, filename_root, prop_code_list):
     203        props = parse_multicolumn_property_data(filename_root + '.txt', self.property_object_map, self.property_lookup_map, prop_code_list)
     204        #(props, prop_map) = parse_UCD_codepoint_name_map(filename_root + '.txt', self.property_lookup_map)
     205        basename = os.path.basename(filename_root)
     206        f = cformat.open_header_file_for_write(basename)
     207        cformat.write_imports(f, ['"PropertyAliases.h"', '"PropertyObjects.h"', '"PropertyValueAliases.h"', '"unicode_set.h"'])
     208        f.write("\nnamespace UCD {\n")
     209        for p in prop_code_list:
     210            self.emit_property(f, p)
     211            property_object = self.property_object_map[p]
     212            if isinstance(property_object, BinaryPropertyObject) or isinstance(property_object, EnumeratedPropertyObject): self.supported_props.append(p)
     213        f.write("}\n\n")
     214        cformat.close_header_file(f)
     215        self.property_data_headers.append(basename)
     216
    202217    def generate_ScriptExtensions_h(self):
    203218        filename_root = 'ScriptExtensions'
     
    338353    # Bidi_Class
    339354    ucd.generate_property_value_file('extracted/DerivedBidiClass', 'bc')
     355    ucd.generate_multicolumn_properties_file('BidiBrackets', ['bpb', 'bpt'])
    340356
    341357    # Indic properties
  • icGREP/icgrep-devel/icgrep/UCD/PropertyObjectTable.h

    r5660 r5661  
    1212#include "PropertyObjects.h"
    1313#include <array>
     14#include "BidiBrackets.h"
    1415#include "Blocks.h"
    1516#include "CompositionExclusions.h"
     
    7980    &SC_ns::property_object,
    8081    &BC_ns::property_object,
    81     new UnsupportedPropertyObject(bpt, PropertyObject::ClassTypeId::EnumeratedProperty),
     82    &BPT_ns::property_object,
    8283    &CCC_ns::property_object,
    8384    &DT_ns::property_object,
  • icGREP/icgrep-devel/icgrep/UCD/PropertyValueAliases.h

    r5660 r5661  
    388388    namespace BPT_ns {
    389389        enum value_t {
    390             c, n, o};
    391         const static std::vector<std::string> enum_names = {
    392             "c", "n", "o"};
    393         const static std::vector<std::string> value_names = {
    394             "Close", "None", "Open"};
     390            n, o, c};
     391        const static std::vector<std::string> enum_names = {
     392            "n", "o", "c"};
     393        const static std::vector<std::string> value_names = {
     394            "None", "Open", "Close"};
    395395        static std::unordered_map<std::string, int> aliases_only_map {{
    396396            }};
Note: See TracChangeset for help on using the changeset viewer.