Ignore:
Timestamp:
Dec 19, 2017, 12:17:52 PM (15 months ago)
Author:
cameron
Message:

Further parser bug fixes and restructuring

File:
1 edited

Legend:

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

    r5787 r5789  
    1313#include <re/re_assertion.h>
    1414#include <re/re_rep.h>
     15#include <llvm/Support/raw_ostream.h>
    1516
    1617
     
    2930RE * RE_Parser_BRE::parse_seq() {
    3031    std::vector<RE *> seq;
    31     if (!mCursor.more() || at("\\|") || ((mGroupsOpen > 0) && at("\\)"))) return makeSeq();
     32    if (!mCursor.more() || at("\\|") || at("\\)")) return makeSeq();
    3233    for (;;) {
    3334        RE * re = parse_next_item();
     
    5455}
    5556
    56 // A parenthesized group.  Input precondition: the opening ( has been consumed
     57// A parenthesized capture group.  Input precondition: the opening \( has been consumed
    5758RE * RE_Parser_BRE::parse_group() {
    58     // Capturing paren group.
    5959    mGroupsOpen++;
    60     RE * captured = parse_alt();
    61     mCaptureGroupCount++;
    62     std::string captureName = "\\" + std::to_string(mCaptureGroupCount);
    63     Name * const capture  = mMemoizer.memoize(makeCapture(captureName, captured));
    64     auto key = std::make_pair("", captureName);
    65     mNameMap.insert(std::make_pair(std::move(key), capture));
    66     if (!accept("\\)")) ParseFailure("Closing parenthesis required.");
     60    RE * captured = parse_capture_body();
     61    require("\\)");
    6762    mGroupsOpen--;
    68     return capture;
     63    return captured;
    6964}
    7065
     
    9388        lb = parse_int();
    9489        if (accept("\\}")) return std::make_pair(lb, lb);
    95         if (!accept(',')) ParseFailure("Expecting , or }");
     90        else require(',');
    9691        if (accept("\\}")) return std::make_pair(lb, Rep::UNBOUNDED_REP);
    9792        ub = parse_int();
    9893        if (ub < lb) ParseFailure("Upper bound less than lower bound");
    9994    }
    100     if (accept("\\}")) return std::make_pair(lb, ub);
    101     else ParseFailure("Expecting \\}");
     95    require("\\}");
     96    return std::make_pair(lb, ub);
    10297}
    10398
Note: See TracChangeset for help on using the changeset viewer.