Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Visual Calc v3.0 - A new dimension for the desktop calculator

, 28 Apr 2006 CPOL
How to start programming a parser.
visualcalc224_bin_20060206.zip
Visual Calc.exe
visualcalc224_lib_20060206.zip
mfc42.dll
msvcrt.dll
msvcp60.dll
visualcalc224_src_20060206.zip
res
About.ico
AboutFrame.bmp
CodeProject.ico
Doxygen.ico
function.ico
Help.ico
ico00001.ico
operator.ico
switch.ico
Visual Calc.ico
visualst.ico
WinXP.ico
Visual Calc.dsw
Visual Calc.dsp
visualcalc300_bin_20060418.zip
VisualCalc.exe
VCalcParser.dll
visualcalc300_lib_20060418.zip
msvcrt.dll
msvcp71.dll
msvcr71.dll
MFC71.dll
visualcalc300_parser-doc_20060418.zip
html
class_c_answer_requested_not_found_exception.png
class_c_closing_parenthesis_expected_exception.png
class_c_constant_assignation_exception.png
class_c_division_by_zero_exception.png
class_c_domain_exception.png
class_c_dom_parameters_must_be_integers_exception.png
class_c_dom_parameters_must_be_positive_exception.png
class_c_dom_parameter_must_be_an_integer_exception.png
class_c_dom_parameter_must_be_positive_exception.png
class_c_factorial_def_for_positive_ints_exception.png
class_c_function_exception.png
class_c_function_not_supported_exception.png
class_c_illegal_use_of_fonction_name_exception.png
class_c_implicit_multiplication_exception.png
class_c_literal_assignation_exception.png
class_c_mathematic_exception.png
class_c_mathematic_expression_expected_exception.png
class_c_math_parameter_must_be_an_integer_exception.png
class_c_math_parameter_must_be_positive_exception.png
class_c_n_must_be_positive_exception.png
class_c_parameter_exception.png
class_c_parameter_out_of_range_exception.png
class_c_parser_exception.png
class_c_period_unexpected_exception.png
class_c_p_must_be_positive_exception.png
class_c_p_must_be_smaller_than_n_exception.png
class_c_syntax_exception.png
class_c_too_few_parameters_exception.png
class_c_too_many_parameters_exception.png
class_c_undefined_variable_exception.png
class_c_unexpected_character_exception.png
class_c_unknown_exception.png
class_c_unknown_function_called_exception.png
class_c_variable_exception.png
class_c_v_calc_parser_exception.png
Copie de form_0.png
Copie de form_1.png
Copie de form_10.png
Copie de form_11.png
Copie de form_12.png
Copie de form_2.png
Copie de form_6.png
Copie de form_7.png
Copie de form_8.png
Copie de form_9.png
doxygen.png
form_0.png
form_1.png
form_10.png
form_11.png
form_12.png
form_2.png
form_3.png
form_4.png
form_5.png
form_6.png
form_7.png
form_8.png
form_9.png
tab_b.gif
tab_l.gif
tab_r.gif
_formulas.tex
visualcalc300_parser-src_20060418.zip
VCalcParser.lib
visualcalc300_src_20060418.zip
bin
lib
VCalcParser
doc
Doxygen.cfg
VisualCalc
res
About.ico
AboutFrame.bmp
CodeProject.ico
Doxygen.ico
errcodes.ico
function.ico
Help.ico
operator.ico
switch.ico
VisualCalc.ico
VisualCalc.manifest
visualst.ico
WinXP.ico
VCalcParser.lib
visualcalcparser250_doc_20060206.zip
doc
Doxygen.cfg
html
class_c_answer_requested_not_found_exception.png
class_c_closing_parenthesis_expected_exception.png
class_c_constant_assignation_exception.png
class_c_division_by_zero_exception.png
class_c_domain_exception.png
class_c_dom_parameters_must_be_integers_exception.png
class_c_dom_parameters_must_be_positive_exception.png
class_c_dom_parameter_must_be_an_integer_exception.png
class_c_dom_parameter_must_be_positive_exception.png
class_c_factorial_def_for_positive_ints_exception.png
class_c_function_exception.png
class_c_function_not_supported_exception.png
class_c_illegal_use_of_fonction_name_exception.png
class_c_implicit_multiplication_exception.png
class_c_literal_assignation_exception.png
class_c_mathematic_exception.png
class_c_mathematic_expression_expected_exception.png
class_c_math_parameter_must_be_an_integer_exception.png
class_c_math_parameter_must_be_positive_exception.png
class_c_n_must_be_positive_exception.png
class_c_parameter_exception.png
class_c_parameter_out_of_range_exception.png
class_c_parser_exception.png
class_c_period_unexpected_exception.png
class_c_p_must_be_positive_exception.png
class_c_p_must_be_smaller_than_n_exception.png
class_c_syntax_exception.png
class_c_too_few_parameters_exception.png
class_c_too_many_parameters_exception.png
class_c_undefined_variable_exception.png
class_c_unexpected_character_exception.png
class_c_unknown_exception.png
class_c_unknown_function_called_exception.png
class_c_variable_exception.png
class_c_v_calc_parser_exception.png
Copie de form_0.png
Copie de form_1.png
Copie de form_10.png
Copie de form_11.png
Copie de form_12.png
Copie de form_2.png
Copie de form_6.png
Copie de form_7.png
Copie de form_8.png
Copie de form_9.png
doxygen.png
form_0.png
form_1.png
form_10.png
form_11.png
form_12.png
form_2.png
form_3.png
form_4.png
form_5.png
form_6.png
form_7.png
form_8.png
form_9.png
tab_b.gif
tab_l.gif
tab_r.gif
_formulas.tex
visualcalcparser250_src_20060206.zip
visualcalc_demo.zip
Visual Calc.exe
visualcalc_libs.zip
msvcp60.dll
mfc42.dll
msvcrt.dll
visualcalc_parser.zip
visualcalc_src.zip
About.ico
AboutFrame.bmp
CodeProject.ico
function.ico
Help.ico
ico00001.ico
operator.ico
switch.ico
Visual Calc.ico
visualst.ico
WinXP.ico
Visual Calc.dsp
Visual Calc.dsw
// VCalcParserException.h: header file
//

#if !defined(__AFX_VCALCPARSEREXCEPTION_H_INCLUDED__)
#define		 __AFX_VCALCPARSEREXCEPTION_H_INCLUDED__

#if _MSC_VER > 1000
#pragma once
#endif


/***************************************************************/
/*     VisualCalc Parser Exceptions hierarchy                  */
/* ----------------------------------------------------------- */
/*  - CVCalcParserException                                    */
/*      - CSyntaxException                                     */
/*          - CUnexpectedCharacterException                    */
/*          - CDigitExpectedException                          */
/*          - CClosingParenthesisExpectedException             */
/*          - CMathematicExpressionExpectedException           */
/*      - CMathematicException                                 */
/*          - CDivisionByZeroException                         */
/*          - CNMustBePositiveException                        */
/*          - CPMustBePositiveException                        */
/*          - CPMustBeSmallerThanNException                    */
/*          - CFactorialDefForPositiveIntsException            */
/*          - CParameterOutOfRangeException                    */
/*          - CMathParameterMustBePositiveException            */
/*          - CMathParameterMustBeAnIntegerException           */
/*      - CFunctionException                                   */
/*          - CUnknownFunctionCalledException                  */
/*          - CImplicitMultiplicationException                 */
/*          - CIllegalUseOfFonctionNameException               */
/*      - CParameterException                                  */
/*          - CTooFewParametersException                       */
/*          - CTooManyParametersException                      */
/*      - CVariableException                                   */
/*          - CConstantAssignationException                    */
/*          - CLiteralAssignationException                     */
/*          - CUndefinedVariableException                      */
/*      - CDomainException                                     */
/*          - CAnswerRequestedNotFoundException                */
/*          - CDomParameterMustBePositiveException             */
/*          - CDomParameterMustBeAnIntegerException            */
/*          - CDomParametersMustBePositiveException            */
/*          - CDomParametersMustBeIntegersException            */
/*      - CParserException                                     */
/*          - CFunctionNotSupportedException                   */
/*          - CUnknownException                                */
/***************************************************************/


#include <STRING>	// std::string


//////////////////////////////////////////////////////
// class CVCalcParserException
//   Base class for VisualCalc Parser Exceptions
//   See 'Exception definitions.txt' for more details
//     about the exceptions Code Numbers and Messages.
class CVCalcParserException {
protected:
	enum ExceptionNumbers {			// Used by the derived classes
		ENB_SYN_UNEXPECTED_CHARACTER			= 1001,
		ENB_SYN_DIGIT_EXPECTED					= 1002,
		ENB_SYN_CLOSING_PARENTHESIS_EXPECTED	= 1003,
		ENB_SYN_MATHEMATIC_EXPRESSION_EXPECTED	= 1004,
		ENB_MTH_DIVISION_BY_ZERO				= 2001,
		ENB_MTH_N_MUST_BE_POSITIVE				= 2002,
		ENB_MTH_P_MUST_BE_POSITIVE				= 2003,
		ENB_MTH_P_MUST_BE_SMALLER_THAN_N		= 2004,
		ENB_MTH_FACTORIAL_DEF_FOR_POSITIVE_INTS	= 2005,
		ENB_MTH_PARAMETER_OUT_OF_RANGE			= 2006,
		ENB_MTH_PARAMETER_MUST_BE_POSITIVE		= 2007,
		ENB_MTH_PARAMETER_MUST_BE_AN_INTEGER	= 2008,
		ENB_FCT_UNKNOWN_FUNCTION_CALLED			= 3001,
		ENB_FCT_IMPLICIT_MULTIPLICATION			= 3002,
		ENB_FCT_ILLEGAL_USE_OF_FUNCTION_NAME	= 3003,
		ENB_PRM_TOO_FEW_PARAMETERS				= 4001,
		ENB_PRM_TOO_MANY_PARAMETERS				= 4002,
		ENB_VAR_CONSTANTASSIGNATION				= 5001,
		ENB_VAR_LITERALASSIGNATION				= 5002,
		ENB_VAR_UNDEFINED_VARIABLE				= 5003,
		ENB_DMN_ANSWER_REQUESTED_NOT_FOUND		= 6001,
		ENB_DMN_PARAMETER_MUST_BE_POSITIVE		= 6002,
		ENB_DMN_PARAMETER_MUST_BE_AN_INTEGER	= 6003,
		ENB_DMN_PARAMETERS_MUST_BE_POSITIVE		= 6004,
		ENB_DMN_PARAMETERS_MUST_BE_INTEGERS		= 6005,
		ENB_PRS_FUNCTION_NOT_SUPPORTED			= 9001,
		ENB_PRS_UNKNOWN_EXCEPTION				= 9009,
		ENB_NONE								= -1
	};

	ExceptionNumbers	m_enExceptionNumber;	// Exception Number
	std::string			m_strExceptionMsg;		// Exception message
	long				m_iErrorPos;			// Position of the error in the source stream

	// Protected to make the class abstract. It must not be possible to instantiate the class
	CVCalcParserException(ExceptionNumbers enExceptionNumber, const std::string& strExceptionMsg, int iErrorPos);
	
public:
	virtual ~CVCalcParserException();
	ExceptionNumbers GetExceptionNumber();	// Returns the exception number
	std::string		 GetMessage();			// Returns the exception description message
	long			 GetErrorPos();			// Returns the Position of the error in the input stream
};



/************************************************************************/
/* CSyntaxException derived classes                                     */
/************************************************************************/

//////////////////////////////////////////////////////
// class CSyntaxException
//   Child class for VisualCalc Syntax Exceptions
class CSyntaxException : public CVCalcParserException {
protected:
	// Protected to make the class abstract. It must not be possible to instantiate the class
	CSyntaxException(ExceptionNumbers enExceptionNumber, const std::string& strExceptionMsg, int iErrorPos);
	
public:
	virtual ~CSyntaxException();
};


// class CUnexpectedCharacterException
//   Child class for VisualCalc Syntax Exceptions
class CUnexpectedCharacterException : public CSyntaxException {
public:
	CUnexpectedCharacterException(char cCharacter, int iErrorPos);
	~CUnexpectedCharacterException();
};


// class CDigitExpectedException
//   Child class for VisualCalc Syntax Exceptions
class CDigitExpectedException : public CSyntaxException {
public:
	CDigitExpectedException(int iErrorPos);
	~CDigitExpectedException();
};


// class CClosingParenthesisExpectedException
//   Child class for VisualCalc Syntax Exceptions
class CClosingParenthesisExpectedException : public CSyntaxException {
public:
	CClosingParenthesisExpectedException(int iErrorPos);
	~CClosingParenthesisExpectedException();
};


// class CMathematicExpressionExpectedException
//   Child class for VisualCalc Syntax Exceptions
class CMathematicExpressionExpectedException : public CSyntaxException {
public:
	CMathematicExpressionExpectedException(int iErrorPos);
	~CMathematicExpressionExpectedException();
};


/************************************************************************/
/* CMathematicException derived classes                                 */
/************************************************************************/

//////////////////////////////////////////////////////
// class CMathematicException
//   Child class for VisualCalc Mathematic Exceptions
class CMathematicException : public CVCalcParserException {
protected:
	// Protected to make the class abstract. It must not be possible to instantiate the class
	CMathematicException(ExceptionNumbers enExceptionNumber, const std::string& strExceptionMsg, int iErrorPos);

public:
	virtual ~CMathematicException();
};


// class CDivisionByZeroException
//   Child class for VisualCalc Mathematic Exceptions
class CDivisionByZeroException : public CMathematicException {
public:
	CDivisionByZeroException(int iErrorPos);
	virtual ~CDivisionByZeroException();
};


// class CNMustBePositiveException
//   Child class for VisualCalc Mathematic Exceptions
class CNMustBePositiveException : public CMathematicException {
public:
	CNMustBePositiveException(int iErrorPos);
	virtual ~CNMustBePositiveException();
};


// class CPMustBePositiveException
//   Child class for VisualCalc Mathematic Exceptions
class CPMustBePositiveException : public CMathematicException {
public:
	CPMustBePositiveException(int iErrorPos);
	virtual ~CPMustBePositiveException();
};


// class CPMustBeSmallerThanNException
//   Child class for VisualCalc Mathematic Exceptions
class CPMustBeSmallerThanNException : public CMathematicException {
public:
	CPMustBeSmallerThanNException(int iErrorPos);
	virtual ~CPMustBeSmallerThanNException();
};


// class CFactorialDefForPositiveIntsException
//   Child class for VisualCalc Mathematic Exceptions
class CFactorialDefForPositiveIntsException : public CMathematicException {
public:
	CFactorialDefForPositiveIntsException(int iErrorPos);
	virtual ~CFactorialDefForPositiveIntsException();
};


// class CParameterOutOfRangeException
//   Child class for VisualCalc Mathematic Exceptions
class CParameterOutOfRangeException : public CMathematicException {
public:
	CParameterOutOfRangeException(int iErrorPos);
	virtual ~CParameterOutOfRangeException();
};


// class CMathParameterMustBePositiveException
//   Child class for VisualCalc Mathematic Exceptions
class CMathParameterMustBePositiveException : public CMathematicException {
public:
	CMathParameterMustBePositiveException(int iErrorPos);
	virtual ~CMathParameterMustBePositiveException();
};


// class CMathParameterMustBeAnIntegerException
//   Child class for VisualCalc Mathematic Exceptions
class CMathParameterMustBeAnIntegerException : public CMathematicException {
public:
	CMathParameterMustBeAnIntegerException(int iErrorPos);
	virtual ~CMathParameterMustBeAnIntegerException();
};



/************************************************************************/
/* CFunctionException derived classes                                   */
/************************************************************************/

//////////////////////////////////////////////////////
// class CFunctionException
//   Child class for VisualCalc Function Exceptions
class CFunctionException : public CVCalcParserException {
protected:
	// Protected to make the class abstract. It must not be possible to instantiate the class
	CFunctionException(ExceptionNumbers enExceptionNumber, const std::string& strExceptionMsg, int iErrorPos);
	
public:
	virtual ~CFunctionException();
};

// class CUnknownFunctionCalledException
//   Child class for VisualCalc Function Exceptions
class CUnknownFunctionCalledException : public CFunctionException {
public:
	CUnknownFunctionCalledException(const std::string& strFunctionName, int iErrorPos);
	virtual ~CUnknownFunctionCalledException();
};

// class CImplicitMultiplicationException
//   Child class for VisualCalc Function Exceptions
class CImplicitMultiplicationException : public CFunctionException {
public:
	CImplicitMultiplicationException(int iErrorPos);
	virtual ~CImplicitMultiplicationException();
};

// class CIllegalUseOfFonctionNameException
//   Child class for VisualCalc Function Exceptions
class CIllegalUseOfFonctionNameException : public CFunctionException {
public:
	CIllegalUseOfFonctionNameException(const std::string& strFunctionName, int iErrorPos);
	virtual ~CIllegalUseOfFonctionNameException();
};



/************************************************************************/
/* CParameterException derived classes                                  */
/************************************************************************/

//////////////////////////////////////////////////////
// class CParameterException
//   Child class for VisualCalc Parameter Exceptions
class CParameterException : public CVCalcParserException {
protected:
	// Protected to make the class abstract. It must not be possible to instantiate the class
	CParameterException(ExceptionNumbers enExceptionNumber, const std::string& strExceptionMsg, int iErrorPos);

public:
	virtual ~CParameterException();
};

// class CTooFewParametersException
//   Child class for VisualCalc Parameter Exceptions
class CTooFewParametersException : public CParameterException {
public:
	CTooFewParametersException(int iErrorPos);
	virtual ~CTooFewParametersException();
};

// class CTooManyParametersException
//   Child class for VisualCalc Parameter Exceptions
class CTooManyParametersException : public CParameterException {
public:
	CTooManyParametersException(int iErrorPos);
	virtual ~CTooManyParametersException();
};



/************************************************************************/
/* CVariableException derived classes                                   */
/************************************************************************/

//////////////////////////////////////////////////////
// class CVariableException
//   Child class for VisualCalc Variable Exceptions
class CVariableException : public CVCalcParserException {
protected:
	// Protected to make the class abstract. It must not be possible to instantiate the class
	CVariableException(ExceptionNumbers enExceptionNumber, const std::string& strExceptionMsg, int iErrorPos);

public:
	virtual ~CVariableException();
};

// class CConstantAssignationException
//   Child class for VisualCalc Variable Exceptions
class CConstantAssignationException : public CVariableException {
public:
	CConstantAssignationException(const std::string& strConstantName, int iErrorPos);
	virtual ~CConstantAssignationException();
};

// class CLiteralAssignationException
//   Child class for VisualCalc Variable Exceptions
class CLiteralAssignationException : public CVariableException {
public:
	CLiteralAssignationException(int iErrorPos);
	virtual ~CLiteralAssignationException();
};

// class CUndefinedVariableException
//   Child class for VisualCalc Variable Exceptions
class CUndefinedVariableException : public CVariableException {
public:
	CUndefinedVariableException(const std::string& strVariableName, int iErrorPos);
	virtual ~CUndefinedVariableException();
};



/************************************************************************/
/* CDomainException derived classes                                     */
/************************************************************************/

//////////////////////////////////////////////////////
// class CDomainException
//   Child class for VisualCalc Domain Exceptions
class CDomainException : public CVCalcParserException {
protected:
	// Protected to make the class abstract. It must not be possible to instantiate the class
	CDomainException(ExceptionNumbers enExceptionNumber, const std::string& strExceptionMsg, int iErrorPos);

public:
	virtual ~CDomainException();
};

// class CAnswerRequestedNotFoundException
//   Child class for VisualCalc Domain Exceptions
class CAnswerRequestedNotFoundException : public CDomainException {
public:
	CAnswerRequestedNotFoundException(int iErrorPos);
	virtual ~CAnswerRequestedNotFoundException();
};

// class CDomParameterMustBePositiveException
//   Child class for VisualCalc Domain Exceptions
class CDomParameterMustBePositiveException : public CDomainException {
public:
	CDomParameterMustBePositiveException(int iErrorPos);
	virtual ~CDomParameterMustBePositiveException();
};

// class CDomParameterMustBeAnIntegerException
//   Child class for VisualCalc Domain Exceptions
class CDomParameterMustBeAnIntegerException : public CDomainException {
public:
	CDomParameterMustBeAnIntegerException(int iErrorPos);
	virtual ~CDomParameterMustBeAnIntegerException();
};

// class CDomParametersMustBePositiveException
//   Child class for VisualCalc Domain Exceptions
class CDomParametersMustBePositiveException : public CDomainException {
public:
	CDomParametersMustBePositiveException(int iErrorPos);
	virtual ~CDomParametersMustBePositiveException();
};

// class CDomParametersMustBeIntegersException
//   Child class for VisualCalc Domain Exceptions
class CDomParametersMustBeIntegersException : public CDomainException {
public:
	CDomParametersMustBeIntegersException(int iErrorPos);
	virtual ~CDomParametersMustBeIntegersException();
};



/************************************************************************/
/* CParserException derived classes                                     */
/************************************************************************/

//////////////////////////////////////////////////////
// class CParserException
//   Child class for VisualCalc general exceptions
class CParserException : public CVCalcParserException {
protected:
	// Protected to make the class abstract. It must not be possible to instantiate the class
	CParserException(ExceptionNumbers enExceptionNumber, const std::string& strExceptionMsg, int iErrorPos);

public:
	virtual ~CParserException();
};

// class CFunctionNotSupportedException
//   Child class for VisualCalc general exceptions
class CFunctionNotSupportedException : public CParserException {
public:
	CFunctionNotSupportedException(const std::string& strFunctionName, int iErrorPos);
	virtual ~CFunctionNotSupportedException();
};

// class CUnknownException
//   Child class for VisualCalc general exceptions
class CUnknownException : public CParserException {
public:
	CUnknownException(int iErrorPos);
	virtual ~CUnknownException();
};


#endif // !defined(__AFX_VCALCPARSEREXCEPTION_H_INCLUDED__)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

toxcct
Software Developer (Senior) Accenture Technology Solutions
France France

Toxcct is an electronics guy who felt in love with programming at the age of 10 when he discovered C to play with Texas-Instruments calculators.
 
Few years later, he discovered "The C++ Language" from Bjarne Stroustrup ; a true transformation in his life.
 
Now, toxcct is experiencing the Web by developing Siebel CRM Applications for a living. He also respects very much the Web Standards (YES, a HTML/CSS code MUST validate !), and plays around with HTML/CSS/Javascript/Ajax/PHP and such.
 
_____
 
After four years of services as a Codeproject MVP, toxcct is now taking some distance as he doesn't like how things are going on the forums. he particularly doesn't accept how some totally ignorant people got the MVP Reward by only being arrogant and insulting while replying on the technical forums.
 


| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141216.1 | Last Updated 28 Apr 2006
Article Copyright 2004 by toxcct
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid