ARTS  2.0.49
parser.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 Oliver Lemke <olemke@core-dump.info>
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 #ifndef parser_h
19 #define parser_h
20 
21 #include <map>
22 #include "agenda_class.h"
23 #include "sourcetext.h"
24 #include "methods.h"
25 
26 
27 class ArtsParser {
28 public:
29  ArtsParser(Agenda& tasklist, String controlfile, const Verbosity& verbosity);
30 
31  void parse_tasklist ();
32 
33 private:
34  void parse_main();
35 
36  void parse_agenda(Agenda& tasklist);
37 
38  void parse_method(Index& id,
39  ArrayOfIndex& output,
40  ArrayOfIndex& input,
41  Agenda& tasks,
42  ArrayOfIndex& auto_vars,
43  Array<TokVal>& auto_vars_values,
44  String& include_file,
45  bool no_eot=false);
46 
47  void parse_generic_input(const MdRecord*& mdd,
48  Index& id,
49  String& methodname,
50  ArrayOfIndex& input,
51  ArrayOfIndex& auto_vars,
52  Array<TokVal>& auto_vars_values,
53  bool& first,
54  bool& still_supergeneric,
55  String& supergeneric_args,
56  Index& supergeneric_index);
57 
58  void parse_generic_output(const MdRecord*& mdd,
59  Index& id,
60  String& methodname,
61  ArrayOfIndex& output,
62  bool& first,
63  bool& still_supergeneric,
64  String& supergeneric_args,
65  Index& supergeneric_index);
66 
67  void parse_specific_input(const MdRecord* mdd,
68  ArrayOfIndex& input,
69  ArrayOfIndex& auto_vars,
70  Array<TokVal>& auto_vars_values,
71  bool& first);
72 
73  void parse_specific_output(const MdRecord* mdd,
74  ArrayOfIndex& output,
75  bool& first);
76 
77  void parse_method_args(const MdRecord*& mdd,
78  Index& id,
79  String& methodname,
80  ArrayOfIndex& output,
81  ArrayOfIndex& input,
82  ArrayOfIndex& auto_vars,
83  Array<TokVal>& auto_vars_values);
84 
86  ArrayOfIndex& auto_vars,
87  Array<TokVal>& auto_vars_values,
88  Index keyword_index);
89 
90  void tasklist_insert_set_delete(const ArrayOfIndex& auto_vars,
91  const Array<TokVal>& auto_vars_values,
92  const Index method_type,
93  Agenda& tasklist);
94 
95  bool is_whitespace(const char c);
96 
97  void eat_whitespace();
98 
99  void eat_whitespace_from_string(String& str, size_t& pos);
100 
101  void read_name(String& name);
102 
104  ArrayOfIndex& auto_vars,
105  Array<TokVal>& auto_vars_values,
106  const String& default_name,
107  const MdRecord* mdd,
108  const Index group);
109 
110  void assertain_character(char c);
111 
112  void parse_String(String& res);
113 
114  void read_integer(String& res);
115 
116  void read_numeric(String& res);
117 
118  void parse_integer(Index& n);
119 
120  void parse_numeric(Numeric& n);
121 
123 
124  void parse_intvector(ArrayOfIndex& res);
125 
126  void parse_numvector(Vector& res);
127 
128  void parse_matrix(Matrix& res);
129 
130  bool parse_numvector_from_string (Vector& res, String& str);
131 
133 
135 
137 
139 
141 
143 };
144 
145 #endif /* parser_h */
146 
Matrix
The Matrix class.
Definition: matpackI.h:767
ArtsParser::parse_specific_output
void parse_specific_output(const MdRecord *mdd, ArrayOfIndex &output, bool &first)
Parse the output WSVs for current method from the controlfile.
Definition: parser.cc:1235
ArtsParser::parse_generic_output
void parse_generic_output(const MdRecord *&mdd, Index &id, String &methodname, ArrayOfIndex &output, bool &first, bool &still_supergeneric, String &supergeneric_args, Index &supergeneric_index)
Parse the generic output WSVs for current method from the controlfile.
Definition: parser.cc:953
ArtsParser::eat_whitespace_from_string
void eat_whitespace_from_string(String &str, size_t &pos)
Eats whitespace from a String.
Definition: parser.cc:1476
ArtsParser::parse_method
void parse_method(Index &id, ArrayOfIndex &output, ArrayOfIndex &input, Agenda &tasks, ArrayOfIndex &auto_vars, Array< TokVal > &auto_vars_values, String &include_file, bool no_eot=false)
Parse the Contents of text as ARTS control input.
Definition: parser.cc:352
ArtsParser::read_integer
void read_integer(String &res)
Reads an integer.
Definition: parser.cc:1731
ArtsParser::parse_generic_input
void parse_generic_input(const MdRecord *&mdd, Index &id, String &methodname, ArrayOfIndex &input, ArrayOfIndex &auto_vars, Array< TokVal > &auto_vars_values, bool &first, bool &still_supergeneric, String &supergeneric_args, Index &supergeneric_index)
Parse the generic input WSVs for current method from the controlfile.
Definition: parser.cc:772
ArtsParser::is_whitespace
bool is_whitespace(const char c)
Returns true if this character is considered whitespace.
Definition: parser.cc:1415
ArtsParser::mcfile
String mcfile
Definition: parser.h:136
ArtsParser::eat_whitespace
void eat_whitespace()
Eats whitespace.
Definition: parser.cc:1440
ArtsParser::parse_specific_input
void parse_specific_input(const MdRecord *mdd, ArrayOfIndex &input, ArrayOfIndex &auto_vars, Array< TokVal > &auto_vars_values, bool &first)
Parse the specific input WSVs for current method from the controlfile.
Definition: parser.cc:1155
ArtsParser::parse_matrix
void parse_matrix(Matrix &res)
Read a Matrix.
Definition: parser.cc:2090
ArtsParser::read_name
void read_name(String &name)
Reads name of method, keyword, or workspace variable.
Definition: parser.cc:1494
ArtsParser::msource
SourceText msource
Definition: parser.h:138
ArtsParser::assertain_character
void assertain_character(char c)
Make sure that the current character is equal to c and go to the next character.
Definition: parser.cc:1657
Agenda
The Agenda class.
Definition: agenda_class.h:44
ArtsParser::parse_intvector
void parse_intvector(ArrayOfIndex &res)
Read a vector of integers.
Definition: parser.cc:1989
Array< Index >
ArtsParser::verbosity
const Verbosity & verbosity
Definition: parser.h:142
agenda_class.h
Declarations for agendas.
ArtsParser::set_gin_to_default
String set_gin_to_default(const MdRecord *mdd, ArrayOfIndex &auto_vars, Array< TokVal > &auto_vars_values, Index keyword_index)
Set generic input to default value.
Definition: parser.cc:473
ArtsParser::parse_numvector_from_string
bool parse_numvector_from_string(Vector &res, String &str)
Read a vector of Numerics from a String.
Definition: parser.cc:2198
ArtsParser::parse_Stringvector
void parse_Stringvector(ArrayOfString &res)
Read a vector of Strings.
Definition: parser.cc:1944
ArtsParser::parse_stringarray_from_string
bool parse_stringarray_from_string(ArrayOfString &res, String &str)
Read an Array of Strings from a String.
Definition: parser.cc:2267
my_basic_string< char >
ArtsParser::parse_agenda
void parse_agenda(Agenda &tasklist)
Parse the Contents of text as ARTS control input.
Definition: parser.cc:215
ArtsParser::parse_method_args
void parse_method_args(const MdRecord *&mdd, Index &id, String &methodname, ArrayOfIndex &output, ArrayOfIndex &input, ArrayOfIndex &auto_vars, Array< TokVal > &auto_vars_values)
Parse method's argument list.
Definition: parser.cc:617
ArtsParser::parse_tasklist
void parse_tasklist()
Public interface to the main function of the parser.
Definition: parser.cc:47
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Verbosity
Definition: messages.h:50
ArtsParser::read_numeric
void read_numeric(String &res)
Reads a floating point number.
Definition: parser.cc:1793
SourceText
A smart class to hold the text for parsing.
Definition: sourcetext.h:37
ArtsParser::mtasklist
Agenda & mtasklist
Definition: parser.h:134
ArtsParser::read_name_or_value
Index read_name_or_value(String &name, ArrayOfIndex &auto_vars, Array< TokVal > &auto_vars_values, const String &default_name, const MdRecord *mdd, const Index group)
Reads name of a workspace variable or a value.
Definition: parser.cc:1548
ArtsParser::ArtsParser
ArtsParser(Agenda &tasklist, String controlfile, const Verbosity &verbosity)
Constructs a new parser.
Definition: parser.cc:36
MdRecord
All information for one workspace method.
Definition: methods.h:42
ArtsParser
Definition: parser.h:27
ArtsParser::parse_numeric
void parse_numeric(Numeric &n)
Use a String stream to parse a floating point number.
Definition: parser.cc:1921
ArtsParser::parse_main
void parse_main()
The main function of the parser.
Definition: parser.cc:58
ArtsParser::parse_numvector
void parse_numvector(Vector &res)
Read a vector of Numerics.
Definition: parser.cc:2034
ArtsParser::parse_integer
void parse_integer(Index &n)
Use a String stream to parse an integer number.
Definition: parser.cc:1908
sourcetext.h
ArtsParser::mcfile_version
Index mcfile_version
Definition: parser.h:140
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
ArtsParser::parse_String
void parse_String(String &res)
Reads a String, complete with quotation marks.
Definition: parser.cc:1683
Vector
The Vector class.
Definition: matpackI.h:555
methods.h
Declaration of the class MdRecord.
ArtsParser::tasklist_insert_set_delete
void tasklist_insert_set_delete(const ArrayOfIndex &auto_vars, const Array< TokVal > &auto_vars_values, const Index method_type, Agenda &tasklist)
Insert Set and Delete methods for automatically allocated output WSVs.
Definition: parser.cc:1340