Source code

This page describes the content of the source files briefly.

The main file contains the function main which is executed when the program is started. It contains a loop where the user can give an expression as input, then calculates and dispays the result. The loop is repeated until the user enters an empty expression, then the program is ended.

The class Parser which is declared in parser.h is the core of the expression parser. This class contains the code required for parsing a string containing a mathematical expression.

To store declared variables, a class Variablelist is used. The class Parser has (amongst others) one Variablelist as data.

These files contain two mathematical functions which are not pre-defined in c++, and therefore had to be written by hand: factorial and sign.

When an error occurs when parsing an expression, an error of class Error is thrown. All possible error messages are stored in the class Error, to make it easy to extend the parser to support multiple languages. All errors have a unique number.

This file just contains some constants used in the parser, for the maximum length of expressions, function names, and variable names.