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


/*
 *  File:       dfa_source_re.cc
 *              $Id: dfa_source_re.cc,v 1.4 2002/05/22 01:31:53 alec Exp $
 *
 *  Author:     Alec Panoviciu (alecu@email.com)
 *
 *  Comments:
 *
 *  Revision history:
 *
 *  $Log: dfa_source_re.cc,v $
 *  Revision 1.4  2002/05/22 01:31:53  alec
 *  cleaned up firstpo/followpos/nullable computation
 *
 *  Revision 1.3  2002/05/01 09:18:26  alec
 *  - vBitset fixes
 *  - FOLLOWPOS written (not tested yet)
 *
 *  Revision 1.2  2002/04/29 17:55:41  alec
 *  regexps almost done
 *
 *  Revision 1.1  2002/04/29 09:40:01  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 "dfa_source_re.hh"
#include "vbitset.hh"

#ifdef DEBUG

int DfaSourceRe::indent_level = 0;

ostream& operator << (ostream &os, const vBitset &v1)
{
  vBitset &v = const_cast(v1);
  vBitset::reference ri = v.begin(), end = v.end();
  for (unsigned int j = 0; ri.neq(end); ri.next(), j++)
    if (ri.get()) os << j << " ";
  return os;
}

void DfaSourceRe::dump (ostream &os) const
{
  os << " @ " << getPos() << " firstPos: " << firstPos
     << "    lastPos: " << lastPos;
}

void ReCatNode::dump (ostream &os) const
{
  format(os) << "."; DfaSourceRe::dump(os); os << endl;
  indent();
  pre->dump(os);
  post->dump(os);
  unindent();
}

void ReOrNode::dump (ostream &os) const
{
  format(os) << "|"; DfaSourceRe::dump(os); os << endl;
  indent();
  pre->dump(os);
  post->dump(os);
  unindent();
}

void ReStarNode::dump (ostream &os) const
{
  format(os) << "*"; DfaSourceRe::dump(os); os << endl;
  indent();
  in->dump(os);
  unindent();
}

void ReCharNode::dump (ostream &os) const
{
  format(os) << "\'" << match << "\' &" << pos;
  DfaSourceRe::dump(os); os << endl;
}

void ReEotNode::dump (ostream &os) const
{
  format(os) << "# &" << pos;
  DfaSourceRe::dump(os); os << endl;
}

void ReLambdaNode::dump (ostream &os) const
{
  format(os) << ",| &" << pos;
  DfaSourceRe::dump(os); os << endl;
}
  
#endif