Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
andreasabel opened this issue Dec 15, 2019 · 0 comments
Closed

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

andreasabel opened this issue Dec 15, 2019 · 0 comments
Assignees
Labels
bug C++ skeleton Issue concerning the generation of skeleton/template AST traversals
Milestone

Comments

@andreasabel
Copy link
Member

andreasabel commented Dec 15, 2019

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.

@andreasabel andreasabel added this to the 2.8.4 milestone Jan 4, 2020
@andreasabel andreasabel self-assigned this Jan 4, 2020
@andreasabel andreasabel added the skeleton Issue concerning the generation of skeleton/template AST traversals label Jan 4, 2020
andreasabel added a commit that referenced this issue Oct 5, 2020
The regression, non-compileable Skeleton.C, was introduced during the
fix of #277 in 4fb4116.

CPP/STL respects position tokens, CPP/NoSTL ignores `position`.
The unification of the Skeleton-generators broke cpp-nostl.

Fixed by workarounds that treat position tokens just as tokens when
useSTL == False.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug C++ skeleton Issue concerning the generation of skeleton/template AST traversals
Projects
None yet
Development

No branches or pull requests

1 participant