xo-reader2: intern for DDefineExpr lhs symbol
This commit is contained in:
parent
9ab828059b
commit
6e7524a730
3 changed files with 15 additions and 2 deletions
|
|
@ -69,6 +69,10 @@ namespace xo {
|
|||
/** pop syntax state machine from top of @ref stack_ **/
|
||||
void pop_ssm();
|
||||
|
||||
/** get unique string copy of @p str. Idempotent for each @p str.
|
||||
**/
|
||||
const DUniqueString * intern_string(std::string_view str);
|
||||
|
||||
/** add variable to current local environment (innermost lexical scope) **/
|
||||
void upsert_var(DVariable * var);
|
||||
|
||||
|
|
|
|||
|
|
@ -412,12 +412,15 @@ namespace xo {
|
|||
}
|
||||
|
||||
void
|
||||
DDefineSsm::on_parsed_symbol(std::string_view sym,
|
||||
DDefineSsm::on_parsed_symbol(std::string_view sym_name,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
if (this->defstate_ == defexprstatetype::def_1) {
|
||||
this->defstate_ = defexprstatetype::def_2;
|
||||
|
||||
const DUniqueString * sym
|
||||
= p_psm->intern_string(sym_name);
|
||||
|
||||
def_expr_.data()->assign_lhs_name(sym);
|
||||
|
||||
// if this is a genuine top-level define (i.e. nesting level = 0),
|
||||
|
|
@ -448,7 +451,7 @@ namespace xo {
|
|||
}
|
||||
|
||||
p_psm->illegal_input_on_symbol("DDefineSsm::on_parsed_symbol",
|
||||
sym,
|
||||
sym_name,
|
||||
this->get_expect_str());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,6 +73,12 @@ namespace xo {
|
|||
this->stack_ = ParserStack::pop(stack_, parser_alloc_);
|
||||
}
|
||||
|
||||
const DUniqueString *
|
||||
ParserStateMachine::intern_string(std::string_view str)
|
||||
{
|
||||
return stringtable_.intern(str);
|
||||
}
|
||||
|
||||
void
|
||||
ParserStateMachine::upsert_var(DVariable * var)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue