Changeset 4390 for icGREP


Ignore:
Timestamp:
Jan 2, 2015, 7:53:04 PM (5 years ago)
Author:
cameron
Message:

Handle ANY, ASSIGNED, ASCII properties

Location:
icGREP/icgrep-devel/icgrep
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/CMakeLists.txt

    r4380 r4390  
    5555add_library(PabloADT pablo/pe_and.cpp pablo/pe_not.cpp pablo/pe_or.cpp  pablo/pabloAST.cpp  pablo/pe_sel.cpp  pablo/pe_xor.cpp pablo/codegenstate.cpp  pablo/symbol_generator.cpp pablo/analysis/useanalysis.cpp pablo/printer_pablos.cpp pablo/pablo_compiler.cpp)
    5656add_library(RegExpADT re/re_re.cpp re/re_cc.cpp re/re_parser.cpp re/re_rep.cpp re/parsefailure.cpp re/re_nullable.cpp re/re_simplifier.cpp re/re_compiler.cpp re/printer_re.cpp re/re_diff.cpp re/re_intersect.cpp)
    57 add_library(CCADT cc/cc_namemap.cpp cc/cc_compiler.cpp utf_encoding.cpp utf8_encoder.cpp unicode_categories.h UCD/CaseFolding_txt.cpp)
     57add_library(CCADT cc/cc_namemap.cpp cc/cc_compiler.cpp utf_encoding.cpp utf8_encoder.cpp UCD/CaseFolding_txt.cpp)
    5858add_library(UCDlib UCD/unicode_set.cpp)
    5959
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r4377 r4390  
    146146       
    147147PabloAST * RE_Compiler::character_class_strm(Name * name, PabloBlock & pb) {
    148     if (name->getType() == Name::Type::UnicodeProperty) {
    149         return pb.createCall(name->getName());
    150     }
     148    Var * var = name->getCompiled();
     149    if (var != nullptr) return var;
    151150    else {
    152         Var * var = name->getCompiled();
    153         if (var == nullptr) {
    154             RE * def = name->getDefinition();
    155             assert(!isa<CC>(def));  //  Names mapping to CCs should have been compiled.
    156             assert(name->getType == Name::Type::Unicode);  //
    157             // compile in top-level block
     151        RE * def = name->getDefinition();
     152        if (def != nullptr) {
    158153            MarkerType m = compile(def, mCG);
    159154            assert(isFinalPositionMarker(m));
     
    162157            return v;
    163158        }
    164         else return var;
     159        else if (name->getType() == Name::Type::UnicodeProperty) {
     160            return pb.createCall(name->getName());
     161        }
     162        else {
     163            throw std::runtime_error("Unresolved name " + name->getName());
     164        }
    165165    }
    166166}
  • icGREP/icgrep-devel/icgrep/resolve_properties.cpp

    r4388 r4390  
    1616#include <re/re_start.h>
    1717#include <re/re_end.h>
    18 
    1918#include <cc/cc_namemap.hpp>
    2019#include "UCD/PropertyAliases.h"
     
    2221#include "UCD/PropertyObjectTable.h"
    2322#include "UCD/PropertyValueAliases.h"
     23
    2424
    2525class UnicodePropertyExpressionError : public std::exception {
     
    155155                // Try as a binary property.
    156156                auto propit = UCD::alias_map.find(v);
    157                 if (propit == UCD::alias_map.end()) {
    158                     throw UnicodePropertyExpressionError("Expected a general category, script or binary property name, but '" + name->getName() + "' found instead");
     157                if (propit != UCD::alias_map.end()) {
     158                    theprop = propit->second;
     159                    if (UCD::property_object_table[theprop]->the_kind == UCD::BinaryProperty) {
     160                        name->setName("__get_" + lowercase(UCD::property_enum_name[theprop]) + "_Y");
     161                        return;
     162                    }
     163                    else {
     164                        throw UnicodePropertyExpressionError("Error: property " + UCD::property_full_name[theprop] + " specified without a value");
     165                    }
    159166                }
    160                 theprop = propit->second;
    161                 if (UCD::property_object_table[theprop]->the_kind == UCD::BinaryProperty) {
    162                     name->setName("__get_" + lowercase(UCD::property_enum_name[theprop]) + "_Y");
     167                // Now try special cases of Unicode TR #18
     168                else if (v == "any") {
     169                    name->setDefinition(re::makeAny());
     170                    return;
     171                }
     172                else if (v == "assigned") {
     173                    re::Name * Cn = re::makeName("Cn", Name::Type::UnicodeProperty);
     174                    resolveProperties(Cn);
     175                    name->setDefinition(re::makeDiff(re::makeAny(), Cn));
     176                    return;
     177                }
     178                else if (v == "ascii") {
     179                    name->setName("__get_blk_ASCII");
    163180                    return;
    164181                }
    165182                else {
    166                     throw UnicodePropertyExpressionError("Error: property " + UCD::property_full_name[theprop] + " specified without a value");
     183                    throw UnicodePropertyExpressionError("Expected a general category, script or binary property name, but '" + name->getName() + "' found instead");
    167184                }
    168185            }
Note: See TracChangeset for help on using the changeset viewer.