Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ebnf_la_node.cc

Go to the documentation of this file.
00001 /*
00002  *  File:       ebnf_la_node.cc
00003  *              $Id: ebnf_la_node.cc,v 1.4 2002/06/13 11:36:38 alec Exp $
00004  *
00005  *  Author:     Alec Panoviciu (alecu@email.com)
00006  * 
00007  *  Comments:
00008  *
00009  *  Revision history:
00010  *
00011  *  $Log: ebnf_la_node.cc,v $
00012  *  Revision 1.4  2002/06/13 11:36:38  alec
00013  *  added #line stuff
00014  *
00015  *  Revision 1.3  2002/05/16 21:34:13  alec
00016  *  parser generation done
00017  *
00018  *  Revision 1.2  2002/05/10 07:15:10  alec
00019  *  parser parse tree ok
00020  *
00021  *  Revision 1.1  2002/05/08 18:17:06  alec
00022  *  *** empty log message ***
00023  *
00024  */
00025 
00026 /*
00027   Copyright (C) 2002 Alexandru Panoviciu (alecu@email.com)
00028 
00029   This program is free software; you can redistribute it and/or modify
00030   it under the terms of the GNU General Public License as published by
00031   the Free Software Foundation; either version 2 of the License, or
00032   (at your option) any later version.
00033 
00034   This program is distributed in the hope that it will be useful,
00035   but WITHOUT ANY WARRANTY; without even the implied warranty of
00036   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00037   GNU General Public License for more details.
00038 
00039   You should have received a copy of the GNU General Public License
00040   along with this program; if not, write to the Free Software
00041   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00042 
00043  */
00044 
00045 
00046 #include "ebnf_la_node.hh"
00047 #include "token_spec.hh"
00048 
00049 #ifdef DEBUG
00050 
00051 ITokenSpec *EbnfLaNode::tokens = NULL;
00052 
00053 int EbnfLaNode::indent_level = 0;
00054 
00055 void EbnfLaNode::dumpAttributes (ostream &os) const
00056 {
00057   os << "[";
00058   if (nullable) os << "n ";
00059   else os << "- ";
00060   if (tokens != NULL)
00061   {
00062     {
00063       os << "FIRST(";
00064       vBitset &v = const_cast<vBitset&>(first);
00065       for (int j = 0; j < v.length(); j++)
00066         if (v[j].get())
00067           os << (*tokens)[j].name() << " ";
00068       os << ")";
00069     }
00070     {
00071       os << "FOLLOW(";
00072       vBitset &v = const_cast<vBitset&>(follow);
00073       for (int j = 0; j < v.length(); j++)
00074         if (v[j].get())
00075           os << (*tokens)[j].name() << " ";
00076       os << ")";
00077     }
00078   }
00079   os << "]";
00080 }
00081 
00082 void EbnfOrNode::dump (ostream &os) const
00083 {
00084   if (laSpec != NULL) laSpec->dump(os);
00085   if (!startCode.empty()) os << "{" << startCode.code << "}";
00086   os << "(";
00087   pre->dump(os);
00088   os << " | ";
00089   post->dump(os);
00090   os << ")";
00091   dumpAttributes(os);
00092   if (!endCode.empty()) os << "{" << endCode.code << "}";
00093 }
00094 
00095 
00096 void EbnfCatNode::dump (ostream &os) const
00097 {
00098   if (laSpec != NULL) laSpec->dump(os);
00099   if (!startCode.empty()) os << "{" << startCode.code << "}";
00100   os << "(";
00101   pre->dump(os);
00102   os << " . ";
00103   post->dump(os);
00104   os << ")";
00105   dumpAttributes(os);
00106   if (!endCode.empty()) os << "{" << endCode.code << "}";
00107 }
00108 
00109 
00110 void EbnfStarNode::dump (ostream &os) const
00111 {
00112   if (laSpec != NULL) laSpec->dump(os);
00113   if (!startCode.empty()) os << "{" << startCode.code << "}";
00114   os << "(";
00115   in->dump(os);
00116   os << ")*";
00117   dumpAttributes(os);
00118   if (!endCode.empty()) os << "{" << endCode.code << "}";
00119 }
00120 
00121 
00122 void EbnfNonterminalNode::dump (ostream &os) const
00123 {
00124   if (laSpec != NULL) laSpec->dump(os);
00125   if (!startCode.empty()) os << "{" << startCode.code << "}";
00126   os << "(";
00127   if (!targetVar.empty()) os << targetVar.code << " = ";
00128   os << nontermName << "(" << actualArgs.code << ")";
00129   os << ")";
00130   dumpAttributes(os);
00131   if (!endCode.empty()) os << "{" << endCode.code << "}";
00132 }
00133 
00134 
00135 void EbnfTerminalNode::dump (ostream &os) const
00136 {
00137   if (laSpec != NULL) laSpec->dump(os);
00138   if (!startCode.empty()) os << "{" << startCode.code << "}";
00139   os << "( ";
00140   os << "<" << terminal.name() << "> ";
00141   os << ")";
00142   dumpAttributes(os);
00143   if (!endCode.empty()) os << "{" << endCode.code << "}";
00144 }
00145 
00146 
00147 void EbnfLambdaNode::dump (ostream &os) const
00148 {
00149   os << "nil";
00150   dumpAttributes(os);
00151 }
00152 
00153 #endif

Generated at Tue Jul 9 21:05:43 2002 for CppCC by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001