ARTS  1.0.222
parser.h
Go to the documentation of this file.
1 /* Copyright (C) 2000, 2001 Stefan Buehler <sbuehler@uni-bremen.de>
2 
3  This program is free software; you can redistribute it and/or modify it
4  under the terms of the GNU General Public License as published by the
5  Free Software Foundation; either version 2, or (at your option) any
6  later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16  USA. */
17 
18 /* Header file for functions and classes related to parsing the
19  control text. */
20 
21 #ifndef parser_h
22 #define parser_h
23 
24 #include "token.h"
25 
32 class MRecord {
33 public:
34  MRecord(const Index id,
35  const Array<TokVal>& values,
36  const ArrayOfIndex& output,
37  const ArrayOfIndex& input)
38  : mid(id),
39  mvalues( values ),
40  moutput( output ),
41  minput( input )
42  {
43  // Initialization of arrays from other array now works correctly.
44  }
45  Index Id() const { return mid; }
46  const Array<TokVal>& Values() const { return mvalues; }
47  const ArrayOfIndex& Output() const { return moutput; }
48  const ArrayOfIndex& Input() const { return minput; }
49 
50 private:
60 };
61 
62 
74 class SourceText {
75 public:
76 
78  SourceText() : mLine(0), mColumn(0) { /* Nothing to be done here. */ };
79 
82  void AppendFile(const String& name);
83 
85  char Current() {
86  return mText[mLine][mColumn];
87  }
88 
93  void AdvanceChar();
94 
98  void AdvanceLine();
99 
101  const String& File();
102 
105  Index Line();
106 
108  Index Column() { return mColumn+1; }
109 
112  void Init();
113 
116  bool& LineBreak() { return mLineBreak; }
117 
120  bool LineBreak() const { return mLineBreak; }
121 
123  friend ostream& operator << (ostream& os, const SourceText& text);
124 
125 private:
126 
129 
132 
135 
138 
141 
145 };
146 
155 void parse_main(Array<MRecord>& tasklist, SourceText& text);
156 
157 
158 #endif
MRecord::mid
Index mid
Method id.
Definition: parser.h:52
SourceText::AppendFile
void AppendFile(const String &name)
Appends contents of file to the source text.
Definition: parser.cc:28
MRecord::Input
const ArrayOfIndex & Input() const
Definition: parser.h:48
SourceText::mColumn
Index mColumn
Column position in the text.
Definition: parser.h:134
SourceText::Init
void Init()
This sets the pointer to the first existing character in the text.
Definition: parser.cc:117
SourceText::mSfName
ArrayOfString mSfName
Names associated with.
Definition: parser.h:140
MRecord::mvalues
Array< TokVal > mvalues
List of parameter values (see methods.h for definition of TokVal).
Definition: parser.h:55
SourceText::mText
ArrayOfString mText
The text.
Definition: parser.h:128
SourceText::LineBreak
bool & LineBreak()
Read the line break flag.
Definition: parser.h:116
MRecord
Method runtime data.
Definition: parser.h:32
SourceText::mLine
Index mLine
Line position in the text.
Definition: parser.h:131
SourceText::operator<<
friend ostream & operator<<(ostream &os, const SourceText &text)
Output operator for SourceText.
Definition: parser.cc:151
SourceText::mLineBreak
bool mLineBreak
Is set to true if the last operation caused a line break.
Definition: parser.h:144
SourceText::SourceText
SourceText()
Default constructor.
Definition: parser.h:78
Array< TokVal >
SourceText::Line
Index Line()
Return the line number, but for the file that is associated with the current position.
Definition: parser.cc:102
SourceText::mSfLine
ArrayOfIndex mSfLine
Remember where which source file starts.
Definition: parser.h:137
SourceText::AdvanceLine
void AdvanceLine()
Advances position pointer by one line.
Definition: parser.cc:65
SourceText::Column
Index Column()
Return the current column.
Definition: parser.h:108
my_basic_string< char >
MRecord::minput
ArrayOfIndex minput
Input workspace variables (for generic methods).
Definition: parser.h:59
MRecord::MRecord
MRecord(const Index id, const Array< TokVal > &values, const ArrayOfIndex &output, const ArrayOfIndex &input)
Definition: parser.h:34
SourceText::File
const String & File()
Return the filename associated with the current position.
Definition: parser.cc:87
parse_main
void parse_main(Array< MRecord > &tasklist, SourceText &text)
The main function of the parser.
Definition: parser.cc:1033
SourceText::LineBreak
bool LineBreak() const
Const version of LineBreak.
Definition: parser.h:120
SourceText
A smart class to hold the text for parsing.
Definition: parser.h:74
MRecord::Values
const Array< TokVal > & Values() const
Definition: parser.h:46
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: arts.h:153
SourceText::Current
char Current()
Return the current character.
Definition: parser.h:85
MRecord::Id
Index Id() const
Definition: parser.h:45
SourceText::AdvanceChar
void AdvanceChar()
Advance position pointer by one character.
Definition: parser.cc:36
token.h
MRecord::moutput
ArrayOfIndex moutput
Output workspace variables (for generic methods).
Definition: parser.h:57
MRecord::Output
const ArrayOfIndex & Output() const
Definition: parser.h:47