59 info.
m_attr.reset(unownedAttr);
64 if (!m_accepted.empty())
65 onError(info,
"Already accepted");
67 std::vector<std::pair<C_StateLR1Ptr,F_OncePostShift>> reduced;
68 C_StateLR1Ptrs nextTops;
70 C_StateLR1Ptrs curTops{m_curTops};
71 while (!reduced.empty() || !curTops.empty() || !m_added)
79 std::tie(iTop,iPostShift) = reduced.back();
82 else if (!curTops.empty())
84 iTop = curTops.back();
87 const auto fromState = state(iTop);
88 for (
auto j:
m_policy.action(fromState, token))
93 C_StateLR1Ptr t{
new C_StateLR1};
95 t->m_StateID =
m_policy.nextState(fromState, token);
99 nextTops.emplace_back(t);
103 iPostShift(nestedGLR);
104 nextTops.insert(nextTops.end(), nestedGLR.m_curTops.begin(), nestedGLR.m_curTops.end());
105 m_accepted.insert(m_accepted.end(), nestedGLR.m_accepted.begin(), nestedGLR.m_accepted.end());
112 if (
auto ret = reduceOn(
m_policy.getAcceptId(), iTop, info))
113 m_accepted.push_back(ret->first);
115 onError(info,
"Reduction error on acception");
120 iPostShift(nestedGLR);
121 for (
auto &k: nestedGLR.m_curTops)
122 m_accepted.push_back(k);
124 if (!nestedGLR.m_accepted.empty())
125 onError(info,
"Doubly accepted");
132 if (
auto ret = reduceOn(prodId, iTop, info))
135 reduced.emplace_back(*ret);
137 curTops.emplace_back(ret->first);
140 onError(info,
"Reduction error on production "+std::to_string(prodId));
143 onError(info,
"Unknown action id "+std::to_string(j));
146 if (nextTops.empty() && m_accepted.empty())
152 auto out =
"Syntax error on token=" +
m_policy.printToken(token);
153 if (
auto *attr = info.
m_attr.get())
154 out.append(
" of attr type ").append(
HRTN(*attr));
156 out +=
" with null attr";
158 if (
const auto n = m_curTops.size())
160 out +=
"\nStack dump";
162 out += std::format(
" on {} paths", n);
166 for (
auto i: m_curTops)
168 out += std::format(
"\nPath[{}]:", ind++);
171 out += std::format(
"\n({},{})\t", i->m_pos.m_Line, i->m_pos.m_Col);
173 out +=
HRTN(*i->m_attr);
175 out += std::format(
"\ts={}\tt={}", i->m_StateID,
m_policy.printToken(i->m_TokenID));
182 m_curTops.swap(nextTops);