Click here to Skip to main content
Licence 
First Posted 2 Sep 2002
Views 41,930
Downloads 576
Bookmarked 27 times

ALXParser - a single expression dBase parser

By | 9 Oct 2002 | Article
A dBASE syntax parser of one expression. Functions and variables are supported.

Example of use parser

Introduction

This is a dBASE language parser with support of functions, variables, evaluation and processing of mistakes. The parser was was written by me and is contained in the CALXParser class. 

The process of calculation is broken on two stages: 

  1. syntactic analysis and filling of structures necessary for calculation, 
  2. execution of the prepared script. 

It has allowed a reduction in execution time when using the parser in the big cycles.

Base methods

These methods are necessary to get the results of analysis of expression.

void Parse(LPCSTR lpszExpression);
VARIANT* Execute();

Methods for work with variables

These methods are intended for definition of variables or change of values.

BOOL AddVariable(LPCSTR szName, VARIANT& varValue);
BOOL DelVariable(LPCSTR szName);
void DelUnusedVariables(LPCSTR szName);

BOOL SetVariableValue(LPCSTR szName, VARIANT& varValue);
BOOL SetVariableValue(VARIANT& varValue);
BOOL GetVariableValue(LPCSTR szName, VARIANT& varValue);
BOOL GetVariableValue(VARIANT& varValue);

LPCSTR GetFirstVariableName();
LPCSTR GetNextVariableName();	

Example

Example of use.

// pointer on result
VARIANT* pvarResult = NULL;

try
{
	// prepare script
	m_Parser.Parse(strExpression);
	// execute script
	pvarResult = m_Parser.Execute();
}
catch(CALXParserException* e)
{
	// processing of errors
	for(int i = 0; i < e->GetErrorCount(); i++)
	{
		e->GetErrorInfo(i);
		e->ReportError();
	}
	e->Delete();
	return;
}

// work with result
// ...

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Alexey

Web Developer

Russian Federation Russian Federation

Member

Year of birth - 1974.
Eeducation - was ended by Kaliningrad State University in 1997.
Now I work as the engineer-programmer in Kaliningrad (RUSSIA).

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralSuper!!! Pinmemberins528:43 6 Jul '09  
Generalwhy you did now give a complete NFA and DFA diagram PinmemberMuhammad Rizwan Arif2:33 18 Dec '03  
GeneralRe: why you did now give a complete NFA and DFA diagram PinmemberAlexey3:43 18 Dec '03  
GeneralGreat job! PinmemberHolger Persch22:38 3 Sep '02  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120528.1 | Last Updated 10 Oct 2002
Article Copyright 2002 by Alexey
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid