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.
void eat_whitespace (SourceText &text)
 Eats whitespace.
void read_name (String &name, SourceText &text)
 Reads name of method, keyword, or workspace variable.
void assertain_character (char c, SourceText &text)
 Make sure that the current character is equal to c and go to the next character.
void parse_String (String &res, SourceText &text)
 Reads a String, complete with quotation marks.
void read_integer (String &res, SourceText &text)
 Reads an integer.
void read_numeric (String &res, SourceText &text)
 Reads a floating point number.
void parse_integer (Index &n, SourceText &text)
 Use a String stream to parse an integer number.
void parse_numeric (Numeric &n, SourceText &text)
 Use a String stream to parse a floating point number.
void parse_Stringvector (ArrayOfString &res, SourceText &text)
 Read a vector of Strings.
void parse_intvector (ArrayOfIndex &res, SourceText &text)
 Read a vector of integers.
void parse_numvector (Vector &res, SourceText &text)
 Read a vector of Numerics.
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.
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.
void parse_main (Array< MRecord > &tasklist, SourceText &text)
 The main function of the parser.


Function Documentation

void assertain_character ( char  c,
SourceText text 
)

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

Exceptions:
UnexpectedChar The character is not right.

Definition at line 262 of file parser.cc.

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
UnexpectedChar Non-whitespace character encountered.

Definition at line 193 of file parser.cc.

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.

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

(Only used for debugging)

Definition at line 151 of file parser.cc.

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:
tasklist Output. The ids and keyword parameter values for the methods to run.
text The input to parse.
MdMap The method map.
WsvMap The workspace variable map.
See also:
eat_whitespace

parse_method

Author:
Stefan Buehler

Definition at line 955 of file parser.cc.

void parse_integer ( Index n,
SourceText text 
)

Use a String stream to parse an integer number.

Definition at line 497 of file parser.cc.

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 572 of file parser.cc.

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:
tasklist Output. The method runtime data that can be used to execute the methods.
text The control text
Author:
Stefan Buehler

Definition at line 1031 of file parser.cc.

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:
id Output. Method id.
values Output. Keyword parameter values for this method.
output Output. Output workspace variables (for generic methods).
input Output. Input workspace variables (for generic methods).
text The 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 684 of file parser.cc.

void parse_numeric ( Numeric n,
SourceText text 
)

Use a String stream to parse a floating point number.

Definition at line 506 of file parser.cc.

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 616 of file parser.cc.

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:
IllegalLinebreak An illegal linebreak has occured.

Definition at line 285 of file parser.cc.

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 528 of file parser.cc.

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:
IllegalLinebreak An illegal linebreak has occured.
UnexpectedChar Unexpected character encountered.

Definition at line 330 of file parser.cc.

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.

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:
IllegalLinebreak Illegal line break.
ParseError Cannot parse this as a number.

Definition at line 388 of file parser.cc.


Generated on Wed Feb 4 08:17:26 2009 for ARTS by  doxygen 1.5.6