www.pudn.com > cppcc.rar > cw_macro_token_expander.cc


/*
 *  File:       cw_macro_token_expander.cc
 *              $Id: cw_macro_token_expander.cc,v 1.2 2002/05/08 10:33:32 alec Exp $
 *
 *  Author:     Alec Panoviciu (alecu@email.com)
 * 
 *  Comments:
 *
 *  Revision history:
 *
 *  $Log: cw_macro_token_expander.cc,v $
 *  Revision 1.2  2002/05/08 10:33:32  alec
 *  *** empty log message ***
 *
 *  Revision 1.1  2002/04/29 17:57:35  alec
 *  *** empty log message ***
 *
 */

/*
  Copyright (C) 2002 Alexandru Panoviciu (alecu@email.com)

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

 */

#include "cw_macro_token_expander.h"
#include "macro_token_expander.hh"


MacroTokenExpander* cw_macroTokenExpander = NULL;

CLINK void MacroTokenExpander_addMacro (char *name_, void *regexp_)
{
  ASSERT(((name_ != NULL) && (regexp_ != NULL)),
         "Bad argument to MacroTokenExpander_addMacro");
  cw_macroTokenExpander->addMacro(string(name_), static_cast(regexp_),
                                  Position(yylineno));
}

CLINK void* MacroTokenExpander_getMacro (char *name_)
{
  ASSERT((name_ != NULL),
        "Bad argument to MacroTokenExpander_addMacro");
  try {
    return cw_macroTokenExpander->getMacro(string(name_));
  } catch (ParseException &ex)
  {
    die(formatError(Position(yylineno), ex));
  }
}