Changeset 4245


Ignore:
Timestamp:
Oct 17, 2014, 8:42:12 AM (4 years ago)
Author:
cameron
Message:

Introduce RE::Any for '.' regexp

Location:
icGREP/icgrep-devel/icgrep/re
Files:
1 added
5 edited

Legend:

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

    r4207 r4245  
    1010#include "re/re_re.h"
    1111#include "re/re_alt.h"
     12#include "re/re_any.h"
    1213#include "re/re_cc.h"
    1314#include "re/re_name.h"
     
    9596        retVal = "Start";
    9697    }
     98    else if (isa<const Any>(re))
     99    {
     100        retVal = "Any";
     101    }
    97102    else
    98103    {
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r4244 r4245  
    88//Regular Expressions
    99#include <re/re_name.h>
     10#include <re/re_any.h>
    1011#include <re/re_start.h>
    1112#include <re/re_end.h>
     
    103104        target = process(rep, target, cg);
    104105    }
     106    else if (isa<Any>(re)) {
     107        // Move the markers forward through any nonfinal UTF-8 bytes to the final position of each character.
     108                PabloAST * marker = cg.createVar(target);
     109        marker = cg.createAnd(marker, cg.createCharClass(m_name_map.find("initial")->second));
     110        marker = cg.createScanThru(marker, cg.createCharClass(m_name_map.find("nonfinal")->second));
     111        PabloAST * dot = cg.createNot(cg.createCharClass(m_name_map.find("LineFeed")->second));
     112        target = cg.createAssign(cg.ssa("dot"), cg.createAdvance(cg.createAnd(marker, dot)));
     113    }
    105114    else if (isa<Start>(re)) {
    106115        PabloAST * sol = cg.createNot(cg.createAdvance(cg.createNot(cg.createCharClass(m_name_map.find("LineFeed")->second))));
     
    198207        target = cg.createAssign(cg.ssa("marker"), unbounded);
    199208    }
     209    else if (isa<Any>(repeated)) {
     210        PabloAST * dot = cg.createNot(cg.createCharClass(m_name_map.find("LineFeed")->second));
     211        PabloAST * unbounded = cg.createVar(target);
     212        unbounded = cg.createAnd(cg.createMatchStar(unbounded, cg.createOr(cg.createCharClass(m_name_map.find("nonfinal")->second), dot)), cg.createCharClass(m_name_map.find("initial")->second));
     213        target = cg.createAssign(cg.ssa("marker"), unbounded);
     214    }
     215
    200216    else {
    201217
     
    233249        throw std::runtime_error("Unexpected Null Value passed to RE Compiler!");
    234250    }
     251    else if (isa<Any>(re)) found = true;
    235252    else if (const Name * name = dyn_cast<const Name>(re)) {
    236253        if ((name->getType() == Name::Type::UnicodeCategory) || (name->getType() == Name::Type::Unicode)) {
  • icGREP/icgrep-devel/icgrep/re/re_parser.cpp

    r4242 r4245  
    108108}
    109109
    110 CC * RE_Parser::parse_any_character() {
    111     CC * cc = makeCC();
    112     cc->insert_range(0, 9);
    113     cc->insert_range(11, CC::UNICODE_MAX);
     110Any * RE_Parser::parse_any_character() {
    114111    ++_cursor;
    115     return cc;
     112    return makeAny();
    116113}
    117114
  • icGREP/icgrep-devel/icgrep/re/re_parser.h

    r4242 r4245  
    99
    1010#include "re_re.h"
    11 #include "re_cc.h"
     11#include "re_any.h"
    1212#include "re_name.h"
    1313
     
    3636    RE * parse_next_token();
    3737
    38     CC * parse_any_character();
     38    Any * parse_any_character();
    3939
    4040    RE * extend_item(RE * re);
  • icGREP/icgrep-devel/icgrep/re/re_re.h

    r4210 r4245  
    2121
    2222class Alt;
     23class Any;
    2324class CC;
    2425class Diff;
     
    3738    enum class ClassTypeId : unsigned {
    3839        Alt
     40        , Any
    3941        , CC
    4042        , Diff
Note: See TracChangeset for help on using the changeset viewer.