BNFC / bnfc

BNF Converter
http://bnfc.digitalgrammars.com/
586 stars 165 forks source link

C++: parser for singleton list rule has wrong reference in semantic action #361

Closed andreasabel closed 3 years ago

andreasabel commented 3 years ago

The C++ backend translates

(:[]). [Char]    ::= "finally" Char;
(:).   [Char]    ::= Char "{" [Char] "}";

to parser rules

ListChar 
  : _KW_finally _CHAR_ 
      { $$ = new ListChar(); $$->push_back($1); result->listchar_ = $$; }    // $1 should be $2
  | _CHAR_ _LBRACE ListChar _RBRACE 
      { $3->push_back($1); $$ = $3; result->listchar_ = $$; }