Changeset 4412


Ignore:
Timestamp:
Jan 8, 2015, 8:41:34 AM (4 years ago)
Author:
cameron
Message:

Command line parameter -i for case-insensitive matching

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

Legend:

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

    r4410 r4412  
    5757namespace icgrep {
    5858
    59 LLVM_Gen_RetVal compile(const Encoding encoding, const std::vector<std::string> regexps, const bool enable_multiplexing) {
     59LLVM_Gen_RetVal compile(const Encoding encoding, const std::vector<std::string> regexps, const ModeFlagSet initialFlags) {
    6060    std::vector<RE *> REs;
    6161    RE * re_ast = nullptr;
     
    6363        try
    6464        {
    65             re_ast = RE_Parser::parse(regexps[i]);
     65            re_ast = RE_Parser::parse(regexps[i], initialFlags);
    6666        }
    6767        catch (ParseFailure failure)
     
    120120    PabloBlock & main = PabloBlock::Create();
    121121
    122     CC_Compiler cc_compiler(main, encoding, enable_multiplexing);
     122    CC_Compiler cc_compiler(main, encoding);
    123123   
    124124    cc_compiler.compileByteClasses(re_ast);
  • icGREP/icgrep-devel/icgrep/compiler.h

    r4328 r4412  
    99
    1010#include <utf_encoding.h>
     11#include <re/re_re.h>
     12#include <re/re_parser.h>
    1113#include <pablo/pablo_compiler.h>
    1214#include <string>
     
    1416namespace icgrep {
    1517
    16 pablo::LLVM_Gen_RetVal compile(const Encoding encoding, const std::vector<std::string> regexps, const bool enable_multiplexing = false);
     18    pablo::LLVM_Gen_RetVal compile(const Encoding encoding, const std::vector<std::string> regexps, const re::ModeFlagSet initialFlags);
    1719
    1820}
  • icGREP/icgrep-devel/icgrep/icgrep.cpp

    r4401 r4412  
    6060    cl::alias ShowFileNamesLong("with-filename", cl::desc("Alias for -H"), cl::aliasopt(ShowFileNames));
    6161   
     62    cl::opt<bool> CaseInsensitive("i", cl::desc("Ignore case distinctions in the pattern and the file."), cl::cat(aRegexSourceOptions));
    6263    cl::opt<bool> ShowLineNumbers("n", cl::desc("Show the line number with each matching line."), cl::cat(bGrepOutputOptions));
    6364    cl::alias ShowLineNumbersLong("line-number", cl::desc("Alias for -n"), cl::aliasopt(ShowLineNumbers));
     
    9899    }
    99100   
    100     const auto llvm_codegen = icgrep::compile(encoding, regexVector, false);
     101    re::ModeFlagSet globalFlags = 0;
     102    if (CaseInsensitive) globalFlags |= re::CASE_INSENSITIVE_MODE_FLAG;
     103   
     104    const auto llvm_codegen = icgrep::compile(encoding, regexVector, globalFlags);
    101105
    102106    if (llvm_codegen.process_block_fptr != 0) {
  • icGREP/icgrep-devel/icgrep/re/re_parser.cpp

    r4409 r4412  
    3030namespace re {
    3131
    32 RE * RE_Parser::parse(const std::string & regular_expression) {
     32RE * RE_Parser::parse(const std::string & regular_expression, ModeFlagSet initialFlags) {
    3333    RE_Parser parser(regular_expression);
     34    parser.fModeFlagSet = initialFlags;
    3435    RE * re = parser.parse_RE();
    3536    if (re == nullptr) {
     
    4041
    4142inline RE_Parser::RE_Parser(const std::string & regular_expression)
    42 : _cursor(regular_expression.begin())
    43 , _end(regular_expression.end())
    44 , fModeFlagSet(0)
    45 {
    46 
    47 }
    48 
     43    : _cursor(regular_expression.begin())
     44    , _end(regular_expression.end())
     45    , fModeFlagSet(0)
     46    {
     47       
     48    }
     49   
    4950RE * makeLookAheadAssertion(RE * r) {
    5051    return makeAssertion(r, Assertion::Kind::Lookahead, Assertion::Sense::Positive);
  • icGREP/icgrep-devel/icgrep/re/re_parser.h

    r4316 r4412  
    2525enum ModeFlagType
    2626    {CASE_INSENSITIVE_MODE_FLAG = 1,
    27      MULTILINE_MODE_FLAG = 2,
    28      DOTALL_MODE_FLAG = 4,
    29      IGNORE_SPACE_MODE_FLAG = 8,
    30      UNIX_LINES_MODE_FLAG = 16};
     27     MULTILINE_MODE_FLAG = 2,      // not currently implemented
     28     DOTALL_MODE_FLAG = 4,         // not currently implemented
     29     IGNORE_SPACE_MODE_FLAG = 8,   // not currently implemented
     30     UNIX_LINES_MODE_FLAG = 16};   // not currently implemented
    3131typedef unsigned ModeFlagSet;
    3232   
     
    3535public:
    3636
    37     static RE * parse(const std::string &input_string);
     37    static RE * parse(const std::string &input_string, ModeFlagSet initialFlags);
    3838
    3939private:
     
    4242
    4343    RE_Parser(const std::string & regular_expression);
     44   
     45    RE_Parser(const std::string & regular_expression, ModeFlagSet initialFlags);
    4446
    4547    RE * parse_RE();
Note: See TracChangeset for help on using the changeset viewer.