Ignore:
Timestamp:
Sep 27, 2014, 11:12:13 PM (5 years ago)
Author:
nmedfort
Message:

Modified RE module to use a LLVM-like dyn_cast system; added 'make' functions to hide RE constructors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/cc_compiler.cpp

    r4187 r4194  
    99#include "utf_encoding.h"
    1010#include "cc_compiler_helper.h"
    11 #include "pe_sel.h"
     11
     12//Pablo Expressions
    1213#include "pe_advance.h"
    1314#include "pe_all.h"
    1415#include "pe_and.h"
     16#include "pe_call.h"
    1517#include "pe_charclass.h"
    1618#include "pe_matchstar.h"
    1719#include "pe_not.h"
    1820#include "pe_or.h"
     21#include "pe_pabloe.h"
     22#include "pe_scanthru.h"
     23#include "pe_sel.h"
    1924#include "pe_var.h"
    2025#include "pe_xor.h"
    2126
    22 #include <math.h>
     27//Pablo Statements
     28#include "ps_pablos.h"
     29#include "ps_assign.h"
     30#include "ps_if.h"
     31#include "ps_while.h"
     32
     33#include "re/re_alt.h"
     34#include "re/re_cc.h"
     35#include "re/re_seq.h"
     36#include "re/re_rep.h"
     37
    2338#include <utility>
    24 #include <iostream>
    2539#include <string>
    2640#include <list>
     
    3145#include <stdlib.h>
    3246#include <stdexcept>
     47
     48using namespace re;
    3349
    3450CC_Compiler::CC_Compiler(const UTF_Encoding encoding, const std::string basis_pattern, const std::string gensym_pattern)
     
    107123
    108124void CC_Compiler::process_re(const RE* re) {
    109     if (const Alt* re_alt = dynamic_cast<const Alt*>(re)) {
     125    if (const Alt* re_alt = dyn_cast<const Alt>(re)) {
    110126        for (const RE * re : *re_alt) {
    111127            process_re(re);
    112128        }
    113129    }
    114     else if (const CC* re_cc = dynamic_cast<const CC*>(re)) {
     130    else if (const CC* re_cc = dyn_cast<const CC>(re)) {
    115131        cc2pablos(re_cc);
    116132    }
    117     else if (const Rep* re_rep = dynamic_cast<const Rep*>(re)) {
     133    else if (const Rep* re_rep = dyn_cast<const Rep>(re)) {
    118134        process_re(re_rep->getRE());
    119135    }
    120     else if (const Seq* re_seq = dynamic_cast<const Seq*>(re)) {
     136    else if (const Seq* re_seq = dyn_cast<const Seq>(re)) {
    121137        for (const RE * re : *re_seq) {
    122138            process_re(re);
     
    179195PabloE* CC_Compiler::make_range(const CodePointType n1, const CodePointType n2)
    180196{
    181     CodePointType diff_bits = n1 ^ n2;
    182197    CodePointType diff_count = 0;
    183198
    184     while (diff_bits > 0)
    185     {
    186         diff_count++;
    187         diff_bits >>= 1;
    188     }
     199    for (CodePointType diff_bits = n1 ^ n2; diff_bits; diff_count++, diff_bits >>= 1);
    189200
    190201    if ((n2 < n1) || (diff_count > mEncoding.getBits()))
     
    195206    const CodePointType mask0 = (static_cast<CodePointType>(1) << diff_count) - 1;
    196207
    197     PabloE* common = bit_pattern_expr(n1 & ~mask0, mEncoding.getMask() ^ mask0);
     208    PabloE * common = bit_pattern_expr(n1 & ~mask0, mEncoding.getMask() ^ mask0);
     209
    198210    if (diff_count == 0) return common;
    199211
Note: See TracChangeset for help on using the changeset viewer.