Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

simth::ParameterDescription::Parser Class Reference

#include <parameterdescription.h>

List of all members.

Public Member Functions

 Parser (const std::string &)
std::string run ()

Static Public Member Functions

static std::string parse (const std::string &)


Detailed Description

A simple arithmetic expression string parser, copied from the "desk calculator" example in Stroustrup's book, chapter 6.1. It accepts the following grammar:

program: END expression END

expression: expression + term expression - term term

term: term / primary term * primary primary

primary: NUMBER

In other words, the operations +,-,*,/ are supported as well as parentheses for grouping. But as soon as a non-number character (i.e. arbitrary string) is found, the parsing is terminated and a simth::token_not_found exception is thrown.


Constructor & Destructor Documentation

simth::ParameterDescription::Parser::Parser const std::string &   ) 
 

Only store the string, don't do anything yet


Member Function Documentation

std::string simth::ParameterDescription::Parser::run  ) 
 

Parse the string.

This parser will only accept number expressions. As soon as a non-number character (i.e. arbitrary string) is found, the parsing is terminated and a simth::token_not_found exception is thrown.

static std::string simth::ParameterDescription::Parser::parse const std::string &   )  [static]
 

Driver for the parser. Returns a string with the evaluated arithmetic expression. If there are any non-number literals in the string, the parsing will be stopped and the input string will be returned unchanged.


Generated on Mon Apr 24 21:19:19 2006 for simthetic by  doxygen 1.4.1