00001 /* Copyright (C) 2000, 2001 Stefan Buehler <sbuehler@uni-bremen.de> 00002 00003 This program is free software; you can redistribute it and/or modify it 00004 under the terms of the GNU General Public License as published by the 00005 Free Software Foundation; either version 2, or (at your option) any 00006 later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00016 USA. */ 00017 00018 /* Header file for functions and classes related to parsing the 00019 control text. */ 00020 00021 #ifndef parser_h 00022 #define parser_h 00023 00024 #include "token.h" 00025 00032 class MRecord { 00033 public: 00034 MRecord(const Index id, 00035 const Array<TokVal>& values, 00036 const ArrayOfIndex& output, 00037 const ArrayOfIndex& input) 00038 : mid(id), 00039 mvalues( values ), 00040 moutput( output ), 00041 minput( input ) 00042 { 00043 // Initialization of arrays from other array now works correctly. 00044 } 00045 Index Id() const { return mid; } 00046 const Array<TokVal>& Values() const { return mvalues; } 00047 const ArrayOfIndex& Output() const { return moutput; } 00048 const ArrayOfIndex& Input() const { return minput; } 00049 00050 private: 00052 Index mid; 00055 Array<TokVal> mvalues; 00057 ArrayOfIndex moutput; 00059 ArrayOfIndex minput; 00060 }; 00061 00062 00074 class SourceText { 00075 public: 00076 00078 SourceText() : mLine(0), mColumn(0) { /* Nothing to be done here. */ }; 00079 00082 void AppendFile(const String& name); 00083 00085 char Current() { 00086 return mText[mLine][mColumn]; 00087 } 00088 00093 void AdvanceChar(); 00094 00098 void AdvanceLine(); 00099 00101 const String& File(); 00102 00105 Index Line(); 00106 00108 Index Column() { return mColumn+1; } 00109 00112 void Init(); 00113 00116 bool& LineBreak() { return mLineBreak; } 00117 00120 bool LineBreak() const { return mLineBreak; } 00121 00123 friend ostream& operator << (ostream& os, const SourceText& text); 00124 00125 private: 00126 00128 ArrayOfString mText; 00129 00131 Index mLine; 00132 00134 Index mColumn; 00135 00137 ArrayOfIndex mSfLine; 00138 00140 ArrayOfString mSfName; 00141 00144 bool mLineBreak; 00145 }; 00146 00155 void parse_main(Array<MRecord>& tasklist, SourceText& text); 00156 00157 00158 #endif