ARTS 2.5.0 (git: 9ee3ac6c)
parser.h
Go to the documentation of this file.
1/* Copyright (C) 2012 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 "methods.h"
24#include "sourcetext.h"
25
27 public:
28 ArtsParser(Agenda& tasklist, String controlfile, const Verbosity& verbosity);
29
30 void parse_tasklist();
31
32 private:
33 typedef struct {
38
39 typedef vector<NamedArgument> NamedArguments;
40
41 void find_named_arguments(vector<NamedArgument>& named_args);
42
44
45 void at_end_of_argument(const String& argname);
46
47 void get_argument_index_by_name(Index& arg_index,
48 NamedArguments& named_args,
49 String name);
50
51 void parse_main();
52
53 void parse_agenda(Agenda& tasklist, const String& agenda_name);
54
55 void parse_method(Index& id,
56 ArrayOfIndex& output,
57 ArrayOfIndex& input,
58 Agenda& tasks,
59 ArrayOfIndex& auto_vars,
60 Array<TokVal>& auto_vars_values,
61 String& include_file,
62 bool no_eot = false);
63
64 void parse_generic_input(const MdRecord*& mdd,
65 Index& id,
66 String& methodname,
67 ArrayOfIndex& input,
68 ArrayOfIndex& auto_vars,
69 Array<TokVal>& auto_vars_values,
70 bool& first,
71 bool& still_supergeneric,
72 String& supergeneric_args,
73 Index& supergeneric_index,
74 NamedArguments& named_args,
75 bool call_by_name);
76
77 void parse_generic_output(const MdRecord*& mdd,
78 Index& id,
79 String& methodname,
80 ArrayOfIndex& output,
81 bool& first,
82 bool& still_supergeneric,
83 String& supergeneric_args,
84 Index& supergeneric_index,
85 NamedArguments& named_args,
86 bool call_by_name);
87
88 void parse_specific_input(const MdRecord* mdd,
89 ArrayOfIndex& input,
90 ArrayOfIndex& auto_vars,
91 Array<TokVal>& auto_vars_values,
92 bool& first,
93 NamedArguments& named_args,
94 bool call_by_name);
95
96 void parse_specific_output(const MdRecord* mdd,
97 ArrayOfIndex& output,
98 bool& first,
99 NamedArguments& named_args,
100 bool call_by_name);
101
102 void parse_method_args(const MdRecord*& mdd,
103 Index& id,
104 String& methodname,
105 ArrayOfIndex& output,
106 ArrayOfIndex& input,
107 ArrayOfIndex& auto_vars,
108 Array<TokVal>& auto_vars_values);
109
111 ArrayOfIndex& auto_vars,
112 Array<TokVal>& auto_vars_values,
113 Index keyword_index);
114
115 void tasklist_insert_set_delete(const ArrayOfIndex& auto_vars,
116 const Array<TokVal>& auto_vars_values,
117 const Index method_type,
118 Agenda& tasklist);
119
120 bool is_whitespace(const char c);
121
122 void eat_whitespace();
123
124 void eat_whitespace_from_string(String& str, size_t& pos);
125
126 void read_name(String& name);
127
129 ArrayOfIndex& auto_vars,
130 Array<TokVal>& auto_vars_values,
131 const String& default_name,
132 const MdRecord* mdd,
133 const Index group);
134
135 void assertain_character(char c);
136
137 void parse_String(String& res);
138
139 void read_integer(String& res);
140
141 void read_numeric(String& res);
142
143 void parse_integer(Index& n);
144
145 void parse_numeric(Numeric& n);
146
148
149 void parse_intvector(ArrayOfIndex& res);
150
151 void parse_numvector(Vector& res);
152
153 void parse_matrix(Matrix& res);
154
156
158
160
162
164
166
168
170};
171
172#endif /* parser_h */
Declarations for agendas.
type upp char * str
The Agenda class.
Definition: agenda_class.h:44
bool parse_stringarray_from_string(ArrayOfString &res, String &str)
Read an Array of Strings from a String.
Definition: parser.cc:2459
void parse_specific_output(const MdRecord *mdd, ArrayOfIndex &output, bool &first, NamedArguments &named_args, bool call_by_name)
Parse the output WSVs for current method from the controlfile.
Definition: parser.cc:1471
const Verbosity & verbosity
Definition: parser.h:169
void parse_numeric(Numeric &n)
Use a String stream to parse a floating point number.
Definition: parser.cc:2085
void parse_tasklist()
Public interface to the main function of the parser.
Definition: parser.cc:50
void read_name(String &name)
Reads name of method, keyword, or workspace variable.
Definition: parser.cc:1723
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:1580
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, NamedArguments &named_args, bool call_by_name)
Parse the generic input WSVs for current method from the controlfile.
Definition: parser.cc:990
Agenda & mtasklist
Definition: parser.h:161
vector< NamedArgument > NamedArguments
Definition: parser.h:39
String mcfile
Definition: parser.h:163
void parse_Stringvector(ArrayOfString &res)
Read a vector of Strings.
Definition: parser.cc:2106
void parse_integer(Index &n)
Use a String stream to parse an integer number.
Definition: parser.cc:2074
void skip_to_next_argument()
Skips forward to the next argument.
Definition: parser.cc:91
void assertain_character(char c)
Make sure that the current character is equal to c and go to the next character.
Definition: parser.cc:1860
SourceText msource
Definition: parser.h:165
void parse_specific_input(const MdRecord *mdd, ArrayOfIndex &input, ArrayOfIndex &auto_vars, Array< TokVal > &auto_vars_values, bool &first, NamedArguments &named_args, bool call_by_name)
Parse the specific input WSVs for current method from the controlfile.
Definition: parser.cc:1371
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:1768
void find_named_arguments(vector< NamedArgument > &named_args)
Find named arguments.
Definition: parser.cc:60
bool parse_intvector_from_string(ArrayOfIndex &res, String &str)
Read an array of integers from a String.
Definition: parser.cc:2330
ArtsParser(Agenda &tasklist, String controlfile, const Verbosity &verbosity)
Constructs a new parser.
Definition: parser.cc:36
bool parse_numvector_from_string(Vector &res, String &str)
Read a vector of Numerics from a String.
Definition: parser.cc:2392
bool is_whitespace(const char c)
Returns true if this character is considered whitespace.
Definition: parser.cc:1657
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:496
void eat_whitespace_from_string(String &str, size_t &pos)
Eats whitespace from a String.
Definition: parser.cc:1708
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:603
void parse_agenda(Agenda &tasklist, const String &agenda_name)
Parse the Contents of text as ARTS control input.
Definition: parser.cc:333
void eat_whitespace()
Eats whitespace.
Definition: parser.cc:1679
void parse_main()
The main function of the parser.
Definition: parser.cc:184
void parse_String(String &res)
Reads a String, complete with quotation marks.
Definition: parser.cc:1881
void get_argument_index_by_name(Index &arg_index, NamedArguments &named_args, String name)
Return the index of the argument with the given name.
Definition: parser.cc:169
void read_numeric(String &res)
Reads a floating point number.
Definition: parser.cc:1975
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:759
void parse_generic_output(const MdRecord *&mdd, Index &id, String &methodname, ArrayOfIndex &output, bool &first, bool &still_supergeneric, String &supergeneric_args, Index &supergeneric_index, NamedArguments &named_args, bool call_by_name)
Parse the generic output WSVs for current method from the controlfile.
Definition: parser.cc:1176
void parse_numvector(Vector &res)
Read a vector of Numerics.
Definition: parser.cc:2188
void read_integer(String &res)
Reads an integer.
Definition: parser.cc:1923
void parse_intvector(ArrayOfIndex &res)
Read a vector of integers.
Definition: parser.cc:2147
void parse_matrix(Matrix &res)
Read a Matrix.
Definition: parser.cc:2239
void at_end_of_argument(const String &argname)
Check if current position in controlfile is at the end of an argument.
Definition: parser.cc:154
Index mcfile_version
Definition: parser.h:167
The Matrix class.
Definition: matpackI.h:1225
All information for one workspace method.
Definition: methods.h:41
A smart class to hold the text for parsing.
Definition: sourcetext.h:36
The Vector class.
Definition: matpackI.h:876
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Declaration of the class MdRecord.
#define c