[aspectc-user] compile error when using puma

Ralf Stephan ralf at ark.in-berlin.de
Mon Dec 5 12:30:58 CET 2005


Hello,
I'm trying to use Puma for manipulating C++ source code. In the old
documentation, there is an example program to delete a class declaration
from a project. As Puma has evolved somewhat, this can't be compiled but
I tried to write a new version which, hoever, can't be made to compile too.

Could you please, help me? When saying  g++ -c file.cc  I get

/usr/local/include/Puma/TraceSyntax.ah:36: error: ‘aspect’ does not name a type

and when saying ag++ -c file.cc I get

error: Execution failed: "ac++" --config "puma.config"  -p. -c "use00.cpp" -o "use00.acc"

Here is file.cc:

#include "Puma/CCParser.h"
#include "Puma/CProject.h"
#include "Puma/ErrorStream.h"
#include "Puma/StringSource.h"
#include "Puma/ManipCommander.h"
#include "Puma/MatchCollector.h"
#include "Puma/CTranslationUnit.h"

#include <stdio.h>

using namespace Puma;

int main (int argc, char **argv)
{
    // two parameters
    char *filename = "desktop.h";
    char *classname = "SPDesktop";

    ErrorStream es;
    CProject project (es, argc, argv, "/home/ralf/tmp/inkscape-0.43/src");
    Unit *unit = project.scanFile (filename);

    const char* prefix = "\\do-decl-specifiers \\any-decl-specifiers ( \\exact \\do-declaration \\in-class-spec class";
    const char* postfix = "\\any-base-spec-list { \\any-member-list } ; )";
    char* matchexpr = new char[strlen (prefix) + strlen (postfix) + strlen (classname) + 1];
    sprintf (matchexpr, "%s %s %s", prefix, classname, postfix);

    CCParser parser;
    CTranslationUnit *tunit = parser.parse (*unit, project);
    
    MatchCollector collector (matchexpr);
    collector.collect (project, *tunit);
    CMatch *match = collector.Match(0);
    CSubMatch *submatch = match->SubMatch(unsigned(0));
    CTree *tree = submatch->Tree(0);
    
    ManipCommander commander;
    commander.kill (tree);
    if (commander.valid())
    {
        cout << "couldn't remove class decl" << endl;
        exit(1);
    }
    commander.commit();

    project.saveMode (CProject::RENAME_OLD, ".bak");
    project.save (unit);

    if (es.severity() < sev_error)
        cout << "success!" << endl;

    return 0;
}

ralf



More information about the aspectc-user mailing list