00001 /* 00002 * File: dfa_source_re.cc 00003 * $Id: dfa_source_re.cc,v 1.4 2002/05/22 01:31:53 alec Exp $ 00004 * 00005 * Author: Alec Panoviciu (alecu@email.com) 00006 * 00007 * Comments: 00008 * 00009 * Revision history: 00010 * 00011 * $Log: dfa_source_re.cc,v $ 00012 * Revision 1.4 2002/05/22 01:31:53 alec 00013 * cleaned up firstpo/followpos/nullable computation 00014 * 00015 * Revision 1.3 2002/05/01 09:18:26 alec 00016 * - vBitset fixes 00017 * - FOLLOWPOS written (not tested yet) 00018 * 00019 * Revision 1.2 2002/04/29 17:55:41 alec 00020 * regexps almost done 00021 * 00022 * Revision 1.1 2002/04/29 09:40:01 alec 00023 * *** empty log message *** 00024 * 00025 */ 00026 00027 /* 00028 Copyright (C) 2002 Alexandru Panoviciu (alecu@email.com) 00029 00030 This program is free software; you can redistribute it and/or modify 00031 it under the terms of the GNU General Public License as published by 00032 the Free Software Foundation; either version 2 of the License, or 00033 (at your option) any later version. 00034 00035 This program is distributed in the hope that it will be useful, 00036 but WITHOUT ANY WARRANTY; without even the implied warranty of 00037 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00038 GNU General Public License for more details. 00039 00040 You should have received a copy of the GNU General Public License 00041 along with this program; if not, write to the Free Software 00042 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00043 00044 */ 00045 00046 #include "dfa_source_re.hh" 00047 #include "vbitset.hh" 00048 00049 #ifdef DEBUG 00050 00051 int DfaSourceRe::indent_level = 0; 00052 00053 ostream& operator << (ostream &os, const vBitset &v1) 00054 { 00055 vBitset &v = const_cast<vBitset&>(v1); 00056 vBitset::reference ri = v.begin(), end = v.end(); 00057 for (unsigned int j = 0; ri.neq(end); ri.next(), j++) 00058 if (ri.get()) os << j << " "; 00059 return os; 00060 } 00061 00062 void DfaSourceRe::dump (ostream &os) const 00063 { 00064 os << " @ " << getPos() << " firstPos: " << firstPos 00065 << " lastPos: " << lastPos; 00066 } 00067 00068 void ReCatNode::dump (ostream &os) const 00069 { 00070 format(os) << "."; DfaSourceRe::dump(os); os << endl; 00071 indent(); 00072 pre->dump(os); 00073 post->dump(os); 00074 unindent(); 00075 } 00076 00077 void ReOrNode::dump (ostream &os) const 00078 { 00079 format(os) << "|"; DfaSourceRe::dump(os); os << endl; 00080 indent(); 00081 pre->dump(os); 00082 post->dump(os); 00083 unindent(); 00084 } 00085 00086 void ReStarNode::dump (ostream &os) const 00087 { 00088 format(os) << "*"; DfaSourceRe::dump(os); os << endl; 00089 indent(); 00090 in->dump(os); 00091 unindent(); 00092 } 00093 00094 void ReCharNode::dump (ostream &os) const 00095 { 00096 format(os) << "\'" << match << "\' &" << pos; 00097 DfaSourceRe::dump(os); os << endl; 00098 } 00099 00100 void ReEotNode::dump (ostream &os) const 00101 { 00102 format(os) << "# &" << pos; 00103 DfaSourceRe::dump(os); os << endl; 00104 } 00105 00106 void ReLambdaNode::dump (ostream &os) const 00107 { 00108 format(os) << ",| &" << pos; 00109 DfaSourceRe::dump(os); os << endl; 00110 } 00111 00112 #endif