Skip to content

C++ backend: Skeleton files broken with user-defined tokens #277

@andreasabel

Description

@andreasabel
Prg. Program ::= Name Name ;
token Name letter+ ;

The --cpp-nostl backend produces this Skeleton.C:

#include "Skeleton.H"

void Skeleton::visitProgram(Program *program) {} //abstract class

void Skeleton::visitPrg(Prg *prg)
{
  /* Code For Prg Goes Here */

  visitName_(prg->name_1);
  visitName_(prg->name_2);
}
void Skeleton::visitName(Name p)
{
  /* Code for Name Goes Here */
}
...

Note the extra underscore in calls visitName_.
I think the (quite ugly) code implementing the skeleton generator makes the type name from the variable name name_1, but expects only names of the form name_ without trailing number.

--The visit-function name of a basic type
funName :: String -> String
funName v =
if "integer_" `isPrefixOf` v then "Integer"
else if "char_" `isPrefixOf` v then "Char"
else if "string_" `isPrefixOf` v then "String"
else if "double_" `isPrefixOf` v then "Double"
else if "ident_" `isPrefixOf` v then "Ident"
else toUpper (head v) : init (tail v) -- User-defined type

See also #239 for a similar problem with the C backend.

Metadata

Metadata

Assignees

Labels

C++bugskeletonIssue concerning the generation of skeleton/template AST traversals

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions