Parser rule is not filling values in Vector properly

70 views Asked by At

Here is my code

std::ifstream ifs("f:/test.txt");
std::string line;

//In header in my code
static std::vector<unsigned long long> v_BF_Char;
static std::vector<unsigned long long> v_Begin_BF_Range;
static std::multimap<uintmax_t, std::string> m_BF_Char;

//qi::int_parser<uintmax_t, 16> hex_int;
static qi::uint_parser<unsigned long long, 16, 2, -1> hex_int; 

while (std::getline(ifs, line))
{
    typedef std::string::const_iterator It;
    It begin = line.begin(), end = line.end();

    // rule for grammer
   //  qi::rule<It, unsigned long long()> braced_hex = '<' >> hex_int >> '>';
    qi::rule<It, uintmax_t()> braced_hex2 = '<' >> hex_int >> '>';
    qi::rule<It, std::vector<unsigned long long>()> braced_hex = '<' >> qi::repeat(1,2)[hex_int] >> '>';
    qi::rule<It, std::vector<unsigned long long>()> braced_hex1 = '[' >> qi::repeat(1,2)[hex_int] >> ']';
    bool beginbfrange_check = qi::phrase_parse(begin, end, *braced_hex >> *braced_hex1 , qi::space, v_Begin_BF_Range);
}

My test.txt Contain the following data

<005d> <00a6> [<0063> <007c> <0064> <007e>]
<51dc> <04001C0180000000000000000EE317BC>
<05001C0180000000> <04001C0180000000000000000EE317BC>
<51dc> <30ea30f330ae30c330c8>
<0000> <fffd>
<003d> <00a5>
<05001C0180000000> <04001C0180000000000000000EE317BC>
<005d> <00a6>
<005e> <007d>
<005f> <0303>
<0060> <2019>

I want to parse <005d> <00a6> [<0063> <007c> <0064> <007e>] this line which is the first line of my text file.

I am parsing it like that

qi::rule<It, uintmax_t()> braced_hex2 = '<' >> hex_int >> '>';
bool beginbfrange_check = qi::phrase_parse(begin, end, *braced_hex2 >> *('[' >> *braced_hex2 >> ']') , qi::space, v_Begin_BF_Range);

Which is working fine but i want to use my optimized rule and when i used it which is

bool beginbfrange_check = qi::phrase_parse(begin, end, *braced_hex >> *braced_hex1 , qi::space, v_Begin_BF_Range);

it works but vector store only 005d and 00a6 values and not store rest of the values the values in vector should be 005d 00a6 0063 007c 0064> 007e

**The problem is with other QI rule **

0

There are 0 answers