ARTS  1.0.222
Functions
parser.cc File Reference
#include "arts.h"
#include <map>
#include "messages.h"
#include "exceptions.h"
#include "file.h"
#include "auto_wsv.h"
#include "methods.h"
#include "parser.h"
#include "wsv_aux.h"

Go to the source code of this file.

Functions

ostream & operator<< (ostream &os, const SourceText &text)
 
bool is_whitespace (const char c)
 Returns true if this character is considered whitespace. More...
 
void eat_whitespace (SourceText &text)
 Eats whitespace. More...
 
void read_name (String &name, SourceText &text)
 Reads name of method, keyword, or workspace variable. More...
 
void assertain_character (char c, SourceText &text)
 Make sure that the current character is equal to c and go to the next character. More...
 
void parse_String (String &res, SourceText &text)
 Reads a String, complete with quotation marks. More...
 
void read_integer (String &res, SourceText &text)
 Reads an integer. More...
 
void read_numeric (String &res, SourceText &text)
 Reads a floating point number. More...
 
void parse_integer (Index &n, SourceText &text)
 Use a String stream to parse an integer number. More...
 
void parse_numeric (Numeric &n, SourceText &text)
 Use a String stream to parse a floating point number. More...
 
void parse_Stringvector (ArrayOfString &res, SourceText &text)
 Read a vector of Strings. More...
 
void parse_intvector (ArrayOfIndex &res, SourceText &text)
 Read a vector of integers. More...
 
void parse_numvector (Vector &res, SourceText &text)
 Read a vector of Numerics. More...
 
bool parse_method (Index &id, Array< TokVal > &values, ArrayOfIndex &output, ArrayOfIndex &input, SourceText &text, const std::map< String, Index > MdMap, const std::map< String, Index > WsvMap)
 Parse the Contents of text as ARTS control input. More...
 
void parse (Array< MRecord > &tasklist, SourceText &text, const std::map< String, Index > MdMap, const std::map< String, Index > WsvMap)
 Parse the Contents of text as ARTS control input. More...
 
void parse_main (Array< MRecord > &tasklist, SourceText &text)
 The main function of the parser. More...
 

Function Documentation

◆ assertain_character()

void assertain_character ( char  c,
SourceText text 
)

Make sure that the current character is equal to c and go to the next character.

Exceptions
UnexpectedCharThe character is not right.

Definition at line 262 of file parser.cc.

◆ eat_whitespace()

void eat_whitespace ( SourceText text)

Eats whitespace.

Comments are a special case of whitespace. Everything from the ‘#’ to the end of the line is eaten.

The whitespace cases implemented here must be consistent with is_whitespace!

See also
is_whitespace

@exceptions UnexpectedChar Non-whitespace character encountered.

Definition at line 193 of file parser.cc.

◆ is_whitespace()

bool is_whitespace ( const char  c)

Returns true if this character is considered whitespace.

This includes the comment sign ‘#’. This function is used by other functions to test for delimiting whitespace.

The whitespace cases implemented here must be consistent with eat_whitespace!

See also
eat_whitespace

Definition at line 168 of file parser.cc.

◆ operator<<()

ostream& operator<< ( ostream &  os,
const SourceText text 
)

(Only used for debugging)

Definition at line 151 of file parser.cc.

◆ parse()

void parse ( Array< MRecord > &  tasklist,
SourceText text,
const std::map< String, Index MdMap,
const std::map< String, Index WsvMap 
)

Parse the Contents of text as ARTS control input.

Parameters
tasklistOutput. The ids and keyword parameter values for the methods to run.
textThe input to parse.
MdMapThe method map.
WsvMapThe workspace variable map.
See also
eat_whitespace
parse_method
Author
Stefan Buehler

Definition at line 957 of file parser.cc.

◆ parse_integer()

void parse_integer ( Index n,
SourceText text 
)

Use a String stream to parse an integer number.

Definition at line 499 of file parser.cc.

◆ parse_intvector()

void parse_intvector ( ArrayOfIndex res,
SourceText text 
)

Read a vector of integers.

This looks as follows in the control file: [123,5,334] Whitespace has to have been eaten before, that is, the current character must be ‘[’.

The empty vector is allowed.

Line breaks are allowed before and after each number. Line breaks inside numbers are not allowed.

See also
parse_integer

Definition at line 574 of file parser.cc.

◆ parse_main()

void parse_main ( Array< MRecord > &  tasklist,
SourceText text 
)

The main function of the parser.

This will parse the entire text. FIXME: Add more documentation here.

Parameters
tasklistOutput. The method runtime data that can be used to execute the methods.
textThe control text
Author
Stefan Buehler

Definition at line 1033 of file parser.cc.

◆ parse_method()

bool parse_method ( Index id,
Array< TokVal > &  values,
ArrayOfIndex output,
ArrayOfIndex input,
SourceText text,
const std::map< String, Index MdMap,
const std::map< String, Index WsvMap 
)

Parse the Contents of text as ARTS control input.

Returns
True: This was the last method.
Parameters
idOutput. Method id.
valuesOutput. Keyword parameter values for this method.
outputOutput. Output workspace variables (for generic methods).
inputOutput. Input workspace variables (for generic methods).
textThe input to parse.
See also
read_name
eat_whitespace
assertain_character
parse_String
parse_integer
parse_numeric
parse_Stringvector
parse_intvector
parse_numvector
Exceptions
UnknownMethod
UnknownWsv
WrongWsvGroup
UnexpectedKeyword
Author
Stefan Buehler

Definition at line 686 of file parser.cc.

◆ parse_numeric()

void parse_numeric ( Numeric n,
SourceText text 
)

Use a String stream to parse a floating point number.

Definition at line 508 of file parser.cc.

◆ parse_numvector()

void parse_numvector ( Vector res,
SourceText text 
)

Read a vector of Numerics.

This looks as follows in the control file: [1.3, 5, 3.4] Whitespace has to have been eaten before, that is, the current character must be ‘[’.

The empty vector is allowed.

Line breaks are allowed before and after each number. Line breaks inside numbers are not allowed.

See also
parse_numeric

Definition at line 618 of file parser.cc.

◆ parse_String()

void parse_String ( String res,
SourceText text 
)

Reads a String, complete with quotation marks.

Whitespace has to have been eaten before, that is, the current character must be the quotation mark ("). Quotation marks inside Strings are currently not possible.

Line breaks inside Strings are not allowed.

Exceptions
IllegalLinebreakAn illegal linebreak has occured.

Definition at line 285 of file parser.cc.

◆ parse_Stringvector()

void parse_Stringvector ( ArrayOfString res,
SourceText text 
)

Read a vector of Strings.

This looks as follows in the control file: ["String1","String2"]

Whitespace has to have been eaten before, that is, the current character must be ‘[’.

The empty vector is allowed.

Quotation marks inside Strings are currently not possible.

Line breaks are allowed before and after each String. Line breaks inside Strings are not allowed.

See also
parse_String

Definition at line 530 of file parser.cc.

◆ read_integer()

void read_integer ( String res,
SourceText text 
)

Reads an integer.

Whitespace has to have been eaten before, that is, the current character must be a number or ‘+’ or ‘-’.

Whitespace or line breaks terminate the scanning! There are no whitespaces allowed anywhere, consisten with ANSI C scanf.

Exceptions
IllegalLinebreakAn illegal linebreak has occured.
UnexpectedCharUnexpected character encountered.

Definition at line 330 of file parser.cc.

◆ read_name()

void read_name ( String name,
SourceText text 
)

Reads name of method, keyword, or workspace variable.

These names may consist only of letters (case matters!), numbers, and underscores. Line break or any other character ends the name.

Whitespace has to have been eaten before. Scanns text for the name, starting at position specified by line and column.

Definition at line 232 of file parser.cc.

◆ read_numeric()

void read_numeric ( String res,
SourceText text 
)

Reads a floating point number.

Whitespace has to have been eaten before, that is, the current character must be a number or ‘+’ or ‘-’.

Example numbers: 23., 1.0, -.3, -3.3e5, +3e8, 1.0E-9

Illegal numbers: ., 3e, e3, 2e-

Whitespace is not allowed inside the number. Line breaks or whitespace terminates the scanning.

Exceptions
IllegalLinebreakIllegal line break.
ParseErrorCannot parse this as a number.

Definition at line 388 of file parser.cc.