summaryrefslogtreecommitdiff
path: root/src/core/xbexp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/xbexp.cpp')
-rwxr-xr-xsrc/core/xbexp.cpp125
1 files changed, 57 insertions, 68 deletions
diff --git a/src/core/xbexp.cpp b/src/core/xbexp.cpp
index d3e8ca8..23bc7c6 100755
--- a/src/core/xbexp.cpp
+++ b/src/core/xbexp.cpp
@@ -83,7 +83,7 @@ xbInt16 xbExp::CalcFunctionResultLen( xbExpNode * n ) const{
n->GetNodeText( sNodeText );
char cReturnType = 0;
if(( iRc = xbase->GetFunctionInfo( sNodeText, cReturnType, iReturnLenCalc, lReturnLenVal )) != XB_NO_ERROR ){
- iErrorStop = 10;
+ iErrorStop = 100;
throw iRc;
}
@@ -95,7 +95,7 @@ xbInt16 xbExp::CalcFunctionResultLen( xbExpNode * n ) const{
// use the length from the child node identified in lReturnLenVal
xbExpNode *nChild = n->GetChild( (xbUInt32) lReturnLenVal - 1 );
if( !nChild ){
- iErrorStop = 20;
+ iErrorStop = 110;
iRc = XB_PARSE_ERROR;
throw iRc;
}
@@ -106,7 +106,7 @@ xbInt16 xbExp::CalcFunctionResultLen( xbExpNode * n ) const{
// use the length from the child node identified in lReturnLenVal
xbExpNode *nChild = n->GetChild( (xbUInt32) lReturnLenVal - 1 );
if( !nChild ){
- iErrorStop = 30;
+ iErrorStop = 120;
iRc = XB_PARSE_ERROR;
throw iRc;
}
@@ -117,7 +117,7 @@ xbInt16 xbExp::CalcFunctionResultLen( xbExpNode * n ) const{
xbExpNode *nChild1 = n->GetChild( 0 );
xbExpNode *nChild2 = n->GetChild( 1 );
if( !nChild1 || !nChild2 ){
- iErrorStop = 40;
+ iErrorStop = 130;
iRc = XB_PARSE_ERROR;
throw iRc;
}
@@ -128,7 +128,7 @@ xbInt16 xbExp::CalcFunctionResultLen( xbExpNode * n ) const{
xbExpNode *nChild2 = n->GetChild( 1 );
xbExpNode *nChild3 = n->GetChild( 2 );
if( !nChild2 || !nChild3 ){
- iErrorStop = 50;
+ iErrorStop = 140;
iRc = XB_PARSE_ERROR;
throw iRc;
}
@@ -148,7 +148,7 @@ xbInt16 xbExp::CalcFunctionResultLen( xbExpNode * n ) const{
}
} else {
- iErrorStop = 100;
+ iErrorStop = 150;
iRc = XB_PARSE_ERROR;
throw iRc;
}
@@ -205,12 +205,12 @@ xbInt16 xbExp::CheckParensAndQuotes( const xbString &sExpression ){
s++;
}
if( iLparenCtr != iRparenCtr ){
- iErrorStop = 10;
+ iErrorStop = 100;
iRc = XB_UNBALANCED_PARENS;
throw iRc;
}
if( bInQuotes ){
- iErrorStop = 20;
+ iErrorStop = 110;
iRc = XB_UNBALANCED_QUOTES;
throw iRc;
}
@@ -369,21 +369,21 @@ xbInt16 xbExp::GetNextToken( xbExpToken &t ){
if((t.sExpression.Len() >= 10 && t.sExpression[1] == '{' && t.sExpression[4] == '/' && t.sExpression[7] == '/') &&
(t.sExpression[10] == '}' || (t.sExpression.Len() >= 12 && t.sExpression[12] == '}'))){
if(( iRc = GetTokenDateConstant( t )) != XB_NO_ERROR ){
- iErrorStop = 10;
+ iErrorStop = 100;
throw iRc;
}
}
// Check for parens
else if( t.sExpression[1] == '(' || t.sExpression[1] == '{' ){
if(( iRc = GetTokenParen( t )) != XB_NO_ERROR ){
- iErrorStop = 20;
+ iErrorStop = 110;
throw iRc;
}
}
// Check for a char constant
else if( t.sExpression[1] == '"' || t.sExpression[1] == '\'' ){
if(( iRc = GetTokenCharConstant( t )) != XB_NO_ERROR ){
- iErrorStop = 30;
+ iErrorStop = 120;
iRc = XB_PARSE_ERROR;
throw iRc;
}
@@ -391,7 +391,7 @@ xbInt16 xbExp::GetNextToken( xbExpToken &t ){
// Check for logical constant
else if( IsLogicalConstant( t.sExpression )){
if(( iRc = GetTokenLogicalConstant( t )) != XB_NO_ERROR ){
- iErrorStop = 40;
+ iErrorStop = 130;
iRc = XB_PARSE_ERROR;
throw iRc;
}
@@ -399,7 +399,7 @@ xbInt16 xbExp::GetNextToken( xbExpToken &t ){
// check for numeric constant
else if( IsNumericConstant( t.sExpression, t.cPrevNodeType )){
if(( iRc = GetTokenNumericConstant( t )) != XB_NO_ERROR ){
- iErrorStop = 50;
+ iErrorStop = 140;
iRc = XB_PARSE_ERROR;
throw iRc;
}
@@ -407,7 +407,7 @@ xbInt16 xbExp::GetNextToken( xbExpToken &t ){
// check for operator
else if( IsOperator( t.sExpression )){
if(( iRc = GetTokenOperator( t )) != XB_NO_ERROR ){
- iErrorStop = 60;
+ iErrorStop = 150;
iRc = XB_PARSE_ERROR;
throw iRc;
}
@@ -415,13 +415,13 @@ xbInt16 xbExp::GetNextToken( xbExpToken &t ){
// check for function
else if( IsFunction( t.sExpression, t.cReturnType )){
if(( iRc = GetTokenFunction( t )) != XB_NO_ERROR ){
- iErrorStop = 70;
+ iErrorStop = 160;
iRc = XB_PARSE_ERROR;
throw iRc;
}
}
else if(( iRc = GetTokenDatabaseField( t )) != XB_NO_ERROR ){
- iErrorStop = 80;
+ iErrorStop = 170;
iRc = XB_PARSE_ERROR;
throw iRc;
}
@@ -429,16 +429,9 @@ xbInt16 xbExp::GetNextToken( xbExpToken &t ){
catch (xbInt16 iRc ){
xbString sMsg;
-
- //t.sExpression;
- // std::cout << ">>>>>>>>>" << sMsg.Str() << "\n";
- // sMsg.Sprintf( "[%d][%s]", iErrorStop, t.sExpression.Str() );
- // sMsg.Sprintf( "xbexp::GetNextToken() Exception Caught. Error Stop = [%d] %s", iErrorStop, t.sExpression.Str());
-
sMsg.Sprintf( "xbexp::GetNextToken() Exception Caught. Error Stop = [%d] iRc = [%d] Expression = [%s]", iErrorStop, iRc, t.sExpression.Str() );sMsg.Sprintf( "xbexp::GetNextToken() Exception Caught. Error Stop = [%d] iRc = [%d] Expression = [%s]", iErrorStop, iRc, t.sExpression.Str() );sMsg.Sprintf( "xbexp::GetNextToken() Exception Caught. Error Stop = [%d] iRc = [%d] Expression = [%s]", iErrorStop, iRc, t.sExpression.Str() );sMsg.Sprintf( "xbexp::GetNextToken() Exception Caught. Error Stop = [%d] iRc = [%d] Expression = [%s]", iErrorStop, iRc, t.sExpression.Str() );
xbase->WriteLogMessage( sMsg.Str() );
}
-
return iRc;
}
@@ -460,7 +453,6 @@ xbInt16 xbExp::GetNumericResult( xbDouble &dResult){
return XB_PARSE_ERROR;
}
}
-
/*************************************************************************/
//! Get result length.
/*!
@@ -573,7 +565,7 @@ xbInt16 xbExp::GetTokenCharConstant( xbExpToken &t ){
} else {
iRc = XB_PARSE_ERROR;
t.iSts = XB_UNBALANCED_QUOTES;
- iErrorStop = 10;
+ iErrorStop = 100;
throw iRc;
}
}
@@ -612,7 +604,7 @@ xbInt16 xbExp::GetTokenDateConstant( xbExpToken &t ){
wBuf[i] = t.sExpression[i+2];
if(( iRc = dt.CTOD( wBuf )) != XB_NO_ERROR ){
- iErrorStop = 10;
+ iErrorStop = 100;
throw iRc;
}
t.sToken.Set( dt.Str() );
@@ -634,7 +626,7 @@ xbInt16 xbExp::GetTokenDateConstant( xbExpToken &t ){
} else {
iRc = XB_PARSE_ERROR;
t.iSts = XB_INVALID_DATE;
- iErrorStop = 20;
+ iErrorStop = 110;
throw iRc;
}
}
@@ -645,7 +637,6 @@ xbInt16 xbExp::GetTokenDateConstant( xbExpToken &t ){
}
return iRc;
}
-
/*************************************************************************/
//! GetTokenField
/*! This method gets a database field token
@@ -973,7 +964,7 @@ xbInt16 xbExp::GetTokenParen( xbExpToken &t ){
t.cReturnType = XB_EXP_UNKNOWN;
t.iSts = XB_UNBALANCED_PARENS;
iRc = XB_PARSE_ERROR;
- iErrorStop = 10;
+ iErrorStop = 100;
throw iRc;
}
}
@@ -1215,7 +1206,7 @@ xbInt16 xbExp::ParseExpression( const xbString &sExpression, xbInt16 iWeight ){
delete nTree;
if(( iRc = CheckParensAndQuotes( sExpression )) != XB_NO_ERROR ){
- iErrorStop = 10;
+ iErrorStop = 100;
throw iRc;
}
@@ -1234,7 +1225,7 @@ xbInt16 xbExp::ParseExpression( const xbString &sExpression, xbInt16 iWeight ){
if( t.cNodeType == XB_EXP_NOTROOT ){
xbExp enr( xbase, dbf );
if(( iRc = enr.ParseExpression( t.sToken, iWeight + 10 )) != XB_NO_ERROR ){
- iErrorStop = 20;
+ iErrorStop = 110;
throw iRc;
}
n = enr.GetTreeHandle();
@@ -1247,7 +1238,7 @@ xbInt16 xbExp::ParseExpression( const xbString &sExpression, xbInt16 iWeight ){
case XB_EXP_CONSTANT:
n = new xbExpNode( t.sToken, t.cNodeType );
if(( iRc = ParseExpressionConstant( t, n )) != XB_NO_ERROR ){
- iErrorStop = 30;
+ iErrorStop = 120;
throw iRc;
}
break;
@@ -1255,7 +1246,7 @@ xbInt16 xbExp::ParseExpression( const xbString &sExpression, xbInt16 iWeight ){
case XB_EXP_FUNCTION:
n = new xbExpNode( t.cNodeType );
if(( iRc = ParseExpressionFunction( t, n, iWeight )) != XB_NO_ERROR ){
- iErrorStop = 40;
+ iErrorStop = 130;
throw iRc;
}
break;
@@ -1263,7 +1254,7 @@ xbInt16 xbExp::ParseExpression( const xbString &sExpression, xbInt16 iWeight ){
case XB_EXP_FIELD:
n = new xbExpNode( t.cNodeType );
if(( iRc = ParseExpressionField( t, n )) != XB_NO_ERROR ){
- iErrorStop = 50;
+ iErrorStop = 140;
throw iRc;
}
break;
@@ -1273,13 +1264,13 @@ xbInt16 xbExp::ParseExpression( const xbString &sExpression, xbInt16 iWeight ){
case XB_EXP_POST_OPERATOR:
n = new xbExpNode( t.sToken, t.cNodeType );
if(( iRc = ParseExpressionOperator( t, n, iWeight )) != XB_NO_ERROR ){
- iErrorStop = 60;
+ iErrorStop = 150;
throw iRc;
}
break;
default:
- iErrorStop = 70;
+ iErrorStop = 160;
iRc = XB_PARSE_ERROR;
throw iRc;
// break;
@@ -1337,7 +1328,7 @@ xbInt16 xbExp::ParseExpression( const xbString &sExpression, xbInt16 iWeight ){
} else{
// should not be stopping on anything but an operator node with one or two children
- iErrorStop = 80;
+ iErrorStop = 170;
iRc = XB_PARSE_ERROR;
throw iRc;
}
@@ -1355,21 +1346,19 @@ xbInt16 xbExp::ParseExpression( const xbString &sExpression, xbInt16 iWeight ){
xbExpNode * nChild1;
xbExpNode * nChild2;
-
while( nWork ){
-
if( nWork->GetReturnType() == XB_EXP_UNKNOWN ){
nWork->GetNodeText( s );
// std::cout << "XB_EXP_UNKNOWN logic [" << s << "][" << nWork->GetChildCnt() << "]\n";
// if this is "-" and child 1 and child 2 are both dates, set this result type to numeric
- if( s == "-" && nWork->GetChildCnt() == 2 &&
+ if( s == "-" && nWork->GetChildCnt() == 2 &&
nWork->GetChild(0)->GetReturnType() == XB_EXP_DATE && nWork->GetChild(1)->GetReturnType() == XB_EXP_DATE )
nWork->SetReturnType( XB_EXP_NUMERIC );
else if( nWork->GetChildCnt() > 0 )
nWork->SetReturnType( nWork->GetChild(0)->GetReturnType());
else{
- iErrorStop = 90;
+ iErrorStop = 180;
iRc = XB_PARSE_ERROR;
throw iRc;
}
@@ -1384,12 +1373,12 @@ xbInt16 xbExp::ParseExpression( const xbString &sExpression, xbInt16 iWeight ){
case XB_EXP_CHAR:
if( nWork->GetNodeType() != XB_EXP_OPERATOR ){
- iErrorStop = 100;
+ iErrorStop = 190;
iRc = XB_PARSE_ERROR;
throw iRc;
}
if( nWork->GetChildCnt() < 2 ){
- iErrorStop = 110;
+ iErrorStop = 200;
iRc = XB_PARSE_ERROR;
throw iRc;
}
@@ -1407,7 +1396,7 @@ xbInt16 xbExp::ParseExpression( const xbString &sExpression, xbInt16 iWeight ){
break;
default:
- iErrorStop = 120;
+ iErrorStop = 210;
iRc = XB_PARSE_ERROR;
throw iRc;
// break;
@@ -1415,12 +1404,12 @@ xbInt16 xbExp::ParseExpression( const xbString &sExpression, xbInt16 iWeight ){
}
if( nWork->IsUnaryOperator() ){
if( nWork->GetChildCnt() != 1 ){
- iErrorStop = 130;
+ iErrorStop = 220;
iRc = XB_PARSE_ERROR;
throw iRc;
}
} else if( nWork->IsOperator() && nWork->GetChildCnt() != 2 ){
- iErrorStop = 140;
+ iErrorStop = 230;
iRc = XB_PARSE_ERROR;
throw iRc;
}
@@ -1513,19 +1502,19 @@ xbInt16 xbExp::ParseExpressionField( xbExpToken &t, xbExpNode *n ){
sFieldName = t.sToken;
}
if( !pDbf ){
- iErrorStop = 10;
+ iErrorStop = 100;
iRc = XB_INVALID_FIELD;
throw iRc;
}
xbInt16 iFieldNo = 0;
if(( iRc = pDbf->GetFieldNo( sFieldName, iFieldNo )) != XB_NO_ERROR ){
- iErrorStop = 20;
+ iErrorStop = 110;
throw iRc;
}
char cFieldType;
if(( iRc = pDbf->GetFieldType( iFieldNo, cFieldType )) != XB_NO_ERROR ){
- iErrorStop = 20;
+ iErrorStop = 120;
throw iRc;
}
n->SetDbfInfo( pDbf, iFieldNo );
@@ -1549,7 +1538,7 @@ xbInt16 xbExp::ParseExpressionField( xbExpToken &t, xbExpNode *n ){
case XB_MEMO_FLD:
default:
- iErrorStop = 30;
+ iErrorStop = 130;
iRc = XB_PARSE_ERROR;
throw iRc;
// break;
@@ -1557,7 +1546,7 @@ xbInt16 xbExp::ParseExpressionField( xbExpToken &t, xbExpNode *n ){
n->SetNodeText( sFieldName );
xbInt16 iResultLen = 0;
if(( iRc = pDbf->GetFieldLen( iFieldNo, iResultLen )) != XB_NO_ERROR ){
- iErrorStop = 30;
+ iErrorStop = 140;
throw iRc;
}
n->SetResultLen( (xbUInt32) iResultLen );
@@ -1587,7 +1576,7 @@ xbInt16 xbExp::ParseExpressionFunction( xbExpToken &t, xbExpNode *n, xbInt16 iWe
// find the first "("
xbUInt32 lPos = t.sToken.Pos( '(' );
if( lPos == 0 ){
- iErrorStop = 10;
+ iErrorStop = 100;
iRc = XB_INVALID_FUNCTION;
throw iRc;
}
@@ -1600,7 +1589,7 @@ xbInt16 xbExp::ParseExpressionFunction( xbExpToken &t, xbExpNode *n, xbInt16 iWe
xbInt16 i = 0;
xbInt32 l = 0;
if(( iRc = xbase->GetFunctionInfo( sFunc, cReturnType, i, l )) != XB_NO_ERROR ){
- iErrorStop = 20;
+ iErrorStop = 110;
throw iRc;
}
n->SetNodeText( sFunc );
@@ -1611,7 +1600,7 @@ xbInt16 xbExp::ParseExpressionFunction( xbExpToken &t, xbExpNode *n, xbInt16 iWe
sParms.Mid( lPos+1, t.sToken.Len() - lPos );
lPos = sParms.GetLastPos( ')' );
if( lPos == 0 ){
- iErrorStop = 30;
+ iErrorStop = 120;
iRc = XB_INVALID_FUNCTION;
throw iRc;
}
@@ -1626,7 +1615,7 @@ xbInt16 xbExp::ParseExpressionFunction( xbExpToken &t, xbExpNode *n, xbInt16 iWe
// create a linked list of parms
xbLinkList<xbString> llParms;
if(( iRc = ParseExpressionFunctionParms( sParms, llParms )) != XB_NO_ERROR ){
- iErrorStop = 40;
+ iErrorStop = 130;
throw iRc;
}
@@ -1636,7 +1625,7 @@ xbInt16 xbExp::ParseExpressionFunction( xbExpToken &t, xbExpNode *n, xbInt16 iWe
while( llN ){
sParm = llN->GetKey();
if(( iRc = enr.ParseExpression( sParm, iWeight + 10 )) != XB_NO_ERROR ){
- iErrorStop = 40;
+ iErrorStop = 140;
throw iRc;
}
n->AddChild( enr.GetTreeHandle());
@@ -1657,7 +1646,7 @@ xbInt16 xbExp::ParseExpressionFunction( xbExpToken &t, xbExpNode *n, xbInt16 iWe
}
if(( iRc = CalcFunctionResultLen( n )) != XB_NO_ERROR ){
- iErrorStop = 50;
+ iErrorStop = 150;
throw iRc;
}
}
@@ -1843,7 +1832,7 @@ xbInt16 xbExp::ProcessExpression( xbInt16 iRecBufSw ){
case XB_EXP_PRE_OPERATOR: // increment value before setting in head node
if( nWork->GetChildCnt() != 1 ){
- iErrorStop = 10;
+ iErrorStop = 100;
iRc = XB_PARSE_ERROR;
throw iRc;
}
@@ -1868,7 +1857,7 @@ xbInt16 xbExp::ProcessExpression( xbInt16 iRecBufSw ){
case XB_EXP_POST_OPERATOR: // increment value after setting in head node
if( nWork->GetChildCnt() != 1 ){
- iErrorStop = 20;
+ iErrorStop = 110;
iRc = XB_PARSE_ERROR;
throw iRc;
}
@@ -1895,14 +1884,14 @@ xbInt16 xbExp::ProcessExpression( xbInt16 iRecBufSw ){
case XB_EXP_FIELD:
if(( dbf = nWork->GetDbf()) == NULL ){
- iErrorStop = 30;
+ iErrorStop = 120;
iRc = XB_PARSE_ERROR;
throw iRc;
}
switch( nWork->GetReturnType()){
case XB_EXP_CHAR:
if(( iRc = dbf->GetField( nWork->GetFieldNo(), sWork1, iRecBufSw )) < XB_NO_ERROR ){
- iErrorStop = 40;
+ iErrorStop = 130;
throw iRc;
}
nWork->SetResult( sWork1 );
@@ -1911,7 +1900,7 @@ xbInt16 xbExp::ProcessExpression( xbInt16 iRecBufSw ){
case XB_EXP_DATE:
if(( iRc = dbf->GetField( nWork->GetFieldNo(), sWork1, iRecBufSw )) < XB_NO_ERROR ){
- iErrorStop = 50;
+ iErrorStop = 140;
throw iRc;
}
if( sWork1 == " " ){
@@ -1924,7 +1913,7 @@ xbInt16 xbExp::ProcessExpression( xbInt16 iRecBufSw ){
case XB_EXP_LOGICAL:
if(( iRc = dbf->GetLogicalField( nWork->GetFieldNo(), bWork, iRecBufSw )) != XB_NO_ERROR ){
- iErrorStop = 60;
+ iErrorStop = 150;
throw iRc;
}
nWork->SetResult( bWork );
@@ -1932,14 +1921,14 @@ xbInt16 xbExp::ProcessExpression( xbInt16 iRecBufSw ){
case XB_EXP_NUMERIC:
if(( iRc = dbf->GetDoubleField( nWork->GetFieldNo(), dWork, iRecBufSw )) != XB_NO_ERROR ){
- iErrorStop = 70;
+ iErrorStop = 160;
throw iRc;
}
nWork->SetResult( dWork );
break;
default:
- iErrorStop = 80;
+ iErrorStop = 170;
iRc = XB_PARSE_ERROR;
throw iRc;
// break;
@@ -1949,7 +1938,7 @@ xbInt16 xbExp::ProcessExpression( xbInt16 iRecBufSw ){
case XB_EXP_OPERATOR:
if(( iRc = ProcessExpressionOperator( nWork )) != XB_NO_ERROR ){
- iErrorStop = 300;
+ iErrorStop = 180;
throw iRc;
}
@@ -1957,13 +1946,13 @@ xbInt16 xbExp::ProcessExpression( xbInt16 iRecBufSw ){
case XB_EXP_FUNCTION:
if(( iRc = ProcessExpressionFunction( nWork, iRecBufSw )) != XB_NO_ERROR ){
- iErrorStop = 400;
+ iErrorStop = 190;
throw iRc;
}
break;
default:
- iErrorStop = 500;
+ iErrorStop = 200;
iRc = XB_PARSE_ERROR;
throw iRc;
// break;