Closed mingodad closed 1 year ago
I'm basing the code shown above on Trace parser operation
from http://benhanson.net/parsertl.html and expanded it to show the rule(lhs) and the value been shifted by using code derived from the case parsertl::action::reduce
and maybe I'm missing something there.
The shift param of 9 is referring to the state machine state (gsm._table[9])
case parsertl::action::shift:
{
const std::string str(tok_start, tok_end);
std::cout << "shift " << sm_entry.param
<< ":" << iter_lex->id
<< " <- " << symbols[iter_lex->id];
if (tok_start != tok_end)
{
const std::string str(tok_start, tok_end);
std::cout << " => " << str;
}
std::cout << '\n';
auto& ud = syn_tree.emplace(iter_lex->id);
ud.value = str;
break;
}
With that change it at least doesn't crash.
Thank you !
But on your example Trace parser operation
you use it.
It's an error there too ?
case parsertl::action::reduce:
{
parsertl::state_machine::id_type_vector_pair &pair_ =
gsm_._rules[results_.entry.param];
reduce_(results_.reduce_id());
shift and reduce are not the same.
I recommend stepping through my example and understanding the use of all the containers and values.
Thank you ! I'm on it.
I'm trying to implement a generic dump parse tree but I'm having trouble to understand the details of the parser/state machine.
And I think that I found a bug because there is only 9 rules (
0-8
) but there is an entry inparsertl::state_machine
with index 9 that is one passing the endshift 9:0 <- $ => *
.Any help is welcome !
Output:
Valgrind output: