SCalc::ParserResult Class Referenceabstract

The result of an SCalc::Session::eval(). More...

`#include <expression.hh>`

Inheritance diagram for SCalc::ParserResult:
[legend]

## Public Member Functions

| ParserResult (Session *s)
| Constructors/desctructors:
Session * | session ()
| The SCalc::Session object used. More...
virtual std::string | pretty_print ()=0
| Pretty printing of the result ?
virtual int | can_delete ()
Conversion functions
ParserResult as such is not directly usable: you need to check its actual type and convert it to an appropriate subtype with these functions.
virtual int | is_expression ()
| Is it a SCalc::Expression ? More...
Expression * | to_expression ()
| Converts to SCalc::Expression. More...
virtual int | is_syntax_error ()
| Is it a SCalc::SyntaxError ? More...
SyntaxError * | to_syntax_error ()
| Converts to SCalc::SyntaxError. More...
virtual int | is_func_def ()
| Is it a SCalc::FuncDef ? More...
FuncDef * | to_func_def ()
| Converts to SCalc::FuncDef. More...

## Detailed Description

The result of an SCalc::Session::eval().

The base class for all the things the parser can return. As the parser can return quite a whole bunch of different things, it is not wise to use SCalc::Expression as the carrier for all. Instead, here comes this small wrapper that enables one to check the return type of everything. A ParserResult can be:

- a SCalc::Expression, when the string evaluated to a normal expression
- a SCalc::FuncDef, when the strings evaluated to a function definition
- a SCalc::SyntaxError, when a syntax error was detected.

## Member Function Documentation

## can_delete()

virtual int SCalc::ParserResult::can_delete | ( |  | ) |

inline virtual

Whether or not we can freely delete this result = nearly always yes, unless it is a named function

Reimplemented in SCalc::FuncDef.

## is_expression()

virtual int SCalc::ParserResult::is_expression | ( |  | ) |

inline virtual

Is it a SCalc::Expression ?

Returns true if the object is a SCalc::Expression or one of its children.

Reimplemented in SCalc::Expression.

Referenced by to_expression().

## is_func_def()

virtual int SCalc::ParserResult::is_func_def | ( |  | ) |

inline virtual

Is it a SCalc::FuncDef ?

Returns true if the object is a SCalc::FuncDef or one of its children.

Reimplemented in SCalc::FuncDef.

Referenced by to_func_def().

## is_syntax_error()

virtual int SCalc::ParserResult::is_syntax_error | ( |  | ) |

inline virtual

Is it a SCalc::SyntaxError ?

Returns true if the object is a SCalc::SyntaxError or one of its children.

Reimplemented in SCalc::SyntaxError.

Referenced by to_syntax_error().

## session()

Session* SCalc::ParserResult::session | ( |  | ) |

inline

The SCalc::Session object used.

Returns the SCalc::Session in which the expression was parsed.

Referenced by SCalc::Expression::evaluable().

## to_expression()

Expression* SCalc::ParserResult::to_expression | ( |  | ) |

inline

Converts to SCalc::Expression.

Returns a SCalc::Expression object or NULL if the object isn't an expression.

References is_expression().

## to_func_def()

FuncDef* SCalc::ParserResult::to_func_def | ( |  | ) |

inline

Converts to SCalc::FuncDef.

Returns a SCalc::FuncDef object or NULL if the object doesn't represent a function definition.

References is_func_def(), and pretty_print().

## to_syntax_error()

SyntaxError* SCalc::ParserResult::to_syntax_error | ( |  | ) |

inline

Converts to SCalc::SyntaxError.

Returns a SCalc::SyntaxError object or NULL if the object doesn't represent a syntax error.

References is_syntax_error().

The documentation for this class was generated from the following file:

- lib/expression.hh