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


/*
 *  File:       ebnf_node.cc
 *              $Id: ebnf_node.cc,v 1.4 2002/05/16 21:35:44 alec Exp $
 *
 *  Author:     Alec Panoviciu (alecu@email.com)
 * 
 *  Comments:
 *
 *  Revision history:
 *
 *  $Log: ebnf_node.cc,v $
 *  Revision 1.4  2002/05/16 21:35:44  alec
 *  parser generation done
 *
 *  Revision 1.3  2002/05/10 18:08:25  alec
 *  *** empty log message ***
 *
 *  Revision 1.2  2002/04/29 09:34:10  alec
 *  scanner ptree building compiles
 *
 */

/*
  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 "ebnf_node.hh"
#include "ebnf_node_algo.hh"

bool EbnfNode::dfTraverse (EbnfNodeAlgo &algo) throw (EbnfNodeAlgoException)
{
  for (int i = 0; i < getChildCount(); i++)
    if (!(*this)[i].dfTraverse(algo))
      return false;

  return algo(*this);
}

bool EbnfNode::rdfTraverse (EbnfNodeAlgo &algo) throw (EbnfNodeAlgoException)
{
  if (algo(*this)) {
    for (int i = 0; i < getChildCount(); i++)
      if (!(*this)[i].rdfTraverse(algo))
        return false;
    return true;
  }
}