1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include "fpattern.ih"
// text without (d)quotes, accepted as-is
FPattern FPattern::rawText(States &states, std::string const &str)
{
size_t length = str.length();
FPattern ret;
ret.d_length = length;
if (length == 0) // pathological case: string without contents
{
Pair pair = states.next2();
states[pair.first] = State(EMPTY, pair.second, 0);
ret = pair;
return ret;
}
size_t *indices = states.next(length + 1);
Pair pair = Pair(*indices, indices[length]);
for (size_t idx = 0; idx != length; ++idx)
states[indices[idx]] = State(str[idx], indices[idx + 1]);
delete [] indices;
ret = pair;
return ret;
}
|