Ignore:
Timestamp:
Sep 28, 2015, 9:27:09 AM (4 years ago)
Author:
cameron
Message:

Work on character name patterns

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_parser.cpp

    r4798 r4803  
    1818#include <UCD/resolve_properties.h>
    1919#include <UCD/CaseFolding_txt.h>
     20#include <toolchain.h>
     21#include "utf_encoding.h"
     22#include <pablo/pablo_compiler.h>
     23#include <do_grep.h>
     24
    2025#include <sstream>
    2126#include <algorithm>
     
    555560    // Embed the nameRE in ";.*$nameRE" to skip the codepoint field of Uname.txt
    556561    RE * embedded = makeSeq({re::makeCC(0x3B), re::makeRep(re::makeAny(), 0, Rep::UNBOUNDED_REP), nameRE});
    557 
    558 
     562    Encoding encoding(Encoding::Type::UTF_8, 8);
    559563    throw ParseFailure("\\N{...} character name expression recognized but not yet supported.");
    560 
    561 
     564    // Debugging needed:
     565    pablo::PabloFunction * nameSearchFunction = re2pablo_compiler(encoding, embedded);
     566    llvm::Function * nameSearchIR = nullptr;
     567   
     568    pablo_function_passes(nameSearchFunction);
     569    pablo::PabloCompiler pablo_compiler;
     570    try {
     571        nameSearchIR = pablo_compiler.compile(nameSearchFunction);
     572        releaseSlabAllocatorMemory();
     573    }
     574    catch (std::runtime_error e) {
     575        releaseSlabAllocatorMemory();
     576        std::cerr << "Runtime error: " << e.what() << std::endl;
     577        exit(1);
     578    }
     579    llvm::ExecutionEngine * engine = JIT_to_ExecutionEngine(nameSearchIR);
     580   
     581    icgrep_Linking(nameSearchIR->getParent(), engine);
     582   
     583    // Ensure everything is ready to go.
     584    engine->finalizeObject();
     585   
     586    void * icgrep_MCptr = engine->getPointerToFunction(nameSearchIR);
     587   
     588    if (icgrep_MCptr) {
     589        GrepExecutor grepEngine(icgrep_MCptr);
     590        grepEngine.setParseCodepointsOption();
     591        grepEngine.doGrep("../Uname.txt");
     592        return grepEngine.getParsedCodepoints();
     593    }
     594    else {
     595        return nullptr;
     596    }
     597   
     598    //engine->freeMachineCodeForFunction(nameSearchIR); // This function only prints a "not supported" message. Reevaluate with LLVM 3.6.
     599    delete engine;
    562600}
    563601
Note: See TracChangeset for help on using the changeset viewer.