2007-01-07 05:00 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbcomp.h
* harbour/include/hbexpra.c
* harbour/include/hbexprb.c
* harbour/include/hbexprc.c
* harbour/include/hbexprop.h
* harbour/source/common/expropt1.c
* harbour/source/common/expropt2.c
* harbour/source/compiler/Makefile
* harbour/source/compiler/cmdcheck.c
* harbour/source/compiler/harbour.c
* harbour/source/compiler/harbour.y
* harbour/source/compiler/harbour.yyc
* harbour/source/compiler/harbour.yyh
* harbour/source/compiler/hbcomp.c
* harbour/source/compiler/hbusage.c
* harbour/source/compiler/ppcomp.c
* harbour/source/macro/Makefile
* harbour/source/macro/macro.y
* harbour/source/macro/macro.yyc
* harbour/source/macro/macro.yyh
* harbour/source/vm/macro.c
* harbour/source/vm/memvars.c
* harbour/source/vm/memvclip.c
* keep prefix definition for bison public symbols in *.y files instead
of passing them as bison arguments to avoid possible mistakes during
*.yy[hc] file generation
! fixed iif() reduction when used as single function parameter
+ add -kM compiler switch - turn off macrotext substitution
* updated <string> + <string> optimization and other macrotext usage
to keep more Clipper compatible behavior
! fixed typo in expression type checking in IIF() reduction - it was
working because wrongly used macros has the same values as the valid
ones
- removed compiler switches and macros for old HB_INLINE() syntax - it
was not supported after last months modifications. Only:
HB_INLINE([params,...]) { C code }
is supported.
! fixed passing parameters by reference in IIF() statement and macro
compiler. The following valid Clipper code:
&("myfunc(<exp>, @var1, @var2)")
was not supported
! do not allow to use references or empty expressions in expression list
AFAIK it's Clipper compatible. If I'm wrong then please fix me but
Clipper allows to use references only as function arguments, 2-nd and
3-rd IIF() argument and as directly created array items ( {...@var...} )
DO ... WITH ... is a special case of function call.
! Changed grammar rules to accept only Clipper compatible parameters.
! fixed typo in macro name in hb_memvarNewParameter() function.
* use HB_FUNC_EXEC(...) instead of HB_FUNCNAME(...)()
This commit is contained in:
@@ -8,6 +8,59 @@
|
||||
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
|
||||
2007-01-07 05:00 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/makefile.bc
|
||||
* harbour/makefile.vc
|
||||
* harbour/include/hbcomp.h
|
||||
* harbour/include/hbexpra.c
|
||||
* harbour/include/hbexprb.c
|
||||
* harbour/include/hbexprc.c
|
||||
* harbour/include/hbexprop.h
|
||||
* harbour/source/common/expropt1.c
|
||||
* harbour/source/common/expropt2.c
|
||||
* harbour/source/compiler/Makefile
|
||||
* harbour/source/compiler/cmdcheck.c
|
||||
* harbour/source/compiler/harbour.c
|
||||
* harbour/source/compiler/harbour.y
|
||||
* harbour/source/compiler/harbour.yyc
|
||||
* harbour/source/compiler/harbour.yyh
|
||||
* harbour/source/compiler/hbcomp.c
|
||||
* harbour/source/compiler/hbusage.c
|
||||
* harbour/source/compiler/ppcomp.c
|
||||
* harbour/source/macro/Makefile
|
||||
* harbour/source/macro/macro.y
|
||||
* harbour/source/macro/macro.yyc
|
||||
* harbour/source/macro/macro.yyh
|
||||
* harbour/source/vm/macro.c
|
||||
* harbour/source/vm/memvars.c
|
||||
* harbour/source/vm/memvclip.c
|
||||
* keep prefix definition for bison public symbols in *.y files instead
|
||||
of passing them as bison arguments to avoid possible mistakes during
|
||||
*.yy[hc] file generation
|
||||
! fixed iif() reduction when used as single function parameter
|
||||
+ add -kM compiler switch - turn off macrotext substitution
|
||||
* updated <string> + <string> optimization and other macrotext usage
|
||||
to keep more Clipper compatible behavior
|
||||
! fixed typo in expression type checking in IIF() reduction - it was
|
||||
working because wrongly used macros has the same values as the valid
|
||||
ones
|
||||
- removed compiler switches and macros for old HB_INLINE() syntax - it
|
||||
was not supported after last months modifications. Only:
|
||||
HB_INLINE([params,...]) { C code }
|
||||
is supported.
|
||||
! fixed passing parameters by reference in IIF() statement and macro
|
||||
compiler. The following valid Clipper code:
|
||||
&("myfunc(<exp>, @var1, @var2)")
|
||||
was not supported
|
||||
! do not allow to use references or empty expressions in expression list
|
||||
AFAIK it's Clipper compatible. If I'm wrong then please fix me but
|
||||
Clipper allows to use references only as function arguments, 2-nd and
|
||||
3-rd IIF() argument and as directly created array items ( {...@var...} )
|
||||
DO ... WITH ... is a special case of function call.
|
||||
! Changed grammar rules to accept only Clipper compatible parameters.
|
||||
! fixed typo in macro name in hb_memvarNewParameter() function.
|
||||
* use HB_FUNC_EXEC(...) instead of HB_FUNCNAME(...)()
|
||||
|
||||
2007-01-05 16:00 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/include/hbexprb.c
|
||||
* make function call optimizations only when hb_compFunCallCheck()
|
||||
|
||||
@@ -183,14 +183,14 @@ extern void hb_compElseIfKill( HB_COMP_DECL );
|
||||
extern void hb_compGenError( HB_COMP_DECL, char * szErrors[], char cPrefix, int iError, const char * szError1, const char * szError2 ); /* generic parsing error management function */
|
||||
extern void hb_compGenWarning( HB_COMP_DECL, char * szWarnings[], char cPrefix, int iWarning, const char * szWarning1, const char * szWarning2); /* generic parsing warning management function */
|
||||
|
||||
extern BOOL hb_compIsValidMacroVar( char *, HB_COMP_DECL ); /* checks if passed variable can be used in macro */
|
||||
extern BOOL hb_compForEachVarError( HB_COMP_DECL, char * ); /* checks if it is FOR EACH enumerator variable and generates a warning */
|
||||
extern BOOL hb_compIsValidMacroText( HB_COMP_DECL, char *, ULONG );
|
||||
extern BOOL hb_compForEachVarError( HB_COMP_DECL, char * ); /* checks if it is FOR EACH enumerator variable and generates a warning */
|
||||
|
||||
extern ULONG hb_compGenJump( LONG, HB_COMP_DECL ); /* generates the pcode to jump to a specific offset */
|
||||
extern ULONG hb_compGenJumpFalse( LONG, HB_COMP_DECL ); /* generates the pcode to jump if false */
|
||||
extern ULONG hb_compGenJumpTrue( LONG, HB_COMP_DECL ); /* generates the pcode to jump if true */
|
||||
extern void hb_compGenJumpHere( ULONG, HB_COMP_DECL ); /* returns the pcode pos where to set a jump offset */
|
||||
extern void hb_compGenJumpThere( ULONG, ULONG, HB_COMP_DECL ); /* sets a jump offset */
|
||||
extern ULONG hb_compGenJump( LONG, HB_COMP_DECL ); /* generates the pcode to jump to a specific offset */
|
||||
extern ULONG hb_compGenJumpFalse( LONG, HB_COMP_DECL ); /* generates the pcode to jump if false */
|
||||
extern ULONG hb_compGenJumpTrue( LONG, HB_COMP_DECL ); /* generates the pcode to jump if true */
|
||||
extern void hb_compGenJumpHere( ULONG, HB_COMP_DECL ); /* returns the pcode pos where to set a jump offset */
|
||||
extern void hb_compGenJumpThere( ULONG, ULONG, HB_COMP_DECL ); /* sets a jump offset */
|
||||
|
||||
extern void hb_compLinePush( HB_COMP_DECL ); /* generates the pcode with the currently compiled source code line */
|
||||
extern void hb_compLinePushIfDebugger( HB_COMP_DECL ); /* generates the pcode with the currently compiled source code line */
|
||||
@@ -361,8 +361,8 @@ extern FILE *hb_comp_errFile;
|
||||
#define HB_COMPFLAG_ARRSTR HB_SM_ARRSTR /* 16 -ks strings as array of bytes */
|
||||
#define HB_COMPFLAG_RT_MACRO HB_SM_RT_MACRO /* 64 -kr */
|
||||
#define HB_COMPFLAG_OPTJUMP 256 /* -kj turn off jump optimalization */
|
||||
#define HB_COMPFLAG_HB_INLINE_PP 512 /* -kI hb_inLine support in PP */
|
||||
#define HB_COMPFLAG_HB_INLINE 1024 /* -ki */
|
||||
#define HB_COMPFLAG_HB_INLINE 512 /* -ki hb_inLine(...) { ... } support */
|
||||
#define HB_COMPFLAG_MACROTEXT 1024 /* -kM turn off macrotext substitution */
|
||||
|
||||
#define HB_COMP_ISSUPPORTED(flag) ( HB_COMP_PARAM->supported & (flag) )
|
||||
|
||||
|
||||
@@ -346,32 +346,6 @@ HB_EXPR_PTR hb_compExprCBVarAdd( HB_EXPR_PTR pCB, char * szVarName, BYTE bType,
|
||||
return pCB;
|
||||
}
|
||||
|
||||
/* Create a new IIF() expression or set arguments
|
||||
*
|
||||
* pIIF is a list of three expressions
|
||||
*/
|
||||
HB_EXPR_PTR hb_compExprNewIIF( HB_EXPR_PTR pExpr, HB_COMP_DECL )
|
||||
{
|
||||
#ifndef HB_MACRO_SUPPORT
|
||||
HB_EXPR_PTR pTmp;
|
||||
|
||||
pExpr->ExprType = HB_ET_IIF;
|
||||
|
||||
pTmp = pExpr->value.asList.pExprList; /* get first expression */
|
||||
if( pTmp->ExprType == HB_ET_NONE )
|
||||
{
|
||||
/* there is no conditional expression e.g. IIF( , true, false )
|
||||
*/
|
||||
hb_compErrorSyntax( HB_COMP_PARAM, pExpr );
|
||||
}
|
||||
#else
|
||||
HB_SYMBOL_UNUSED( HB_COMP_PARAM );
|
||||
pExpr->ExprType = HB_ET_IIF;
|
||||
#endif
|
||||
|
||||
return pExpr;
|
||||
}
|
||||
|
||||
/* Create function call
|
||||
*/
|
||||
HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COMP_DECL )
|
||||
@@ -1025,7 +999,7 @@ HB_EXPR_PTR hb_compExprSetGetBlock( HB_EXPR_PTR pExpr, HB_COMP_DECL )
|
||||
/* create ( var==nil, <pExpr>, <pExpr>:=var ) */
|
||||
pIIF = hb_compExprAddListExpr( pIIF, pSet );
|
||||
/* create IIF() expression */
|
||||
pIIF = hb_compExprNewIIF( pIIF, HB_COMP_PARAM );
|
||||
pIIF = hb_compExprNewIIF( pIIF );
|
||||
/* create a codeblock
|
||||
*/
|
||||
return hb_compExprAddCodeblockExpr( hb_compExprCBVarAdd(
|
||||
|
||||
@@ -334,31 +334,11 @@ static HB_EXPR_FUNC( hb_compExprUseString )
|
||||
if( HB_COMP_PARAM->fTextSubst )
|
||||
#endif
|
||||
{
|
||||
BOOL bUseTextSubst;
|
||||
BOOL bValidMacro = hb_compExprIsValidMacro( pSelf->value.asString.string,
|
||||
pSelf->ulLength, &bUseTextSubst, HB_COMP_PARAM );
|
||||
if( bUseTextSubst )
|
||||
if( hb_compIsValidMacroText( HB_COMP_PARAM,
|
||||
pSelf->value.asString.string,
|
||||
pSelf->ulLength ) )
|
||||
{
|
||||
if( HB_SUPPORT_HARBOUR )
|
||||
{
|
||||
if( bValidMacro )
|
||||
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROTEXT );
|
||||
else
|
||||
{
|
||||
hb_compErrorMacro( HB_COMP_PARAM, pSelf->value.asString.string );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Clipper always generates macro substitution pcode
|
||||
* even if it is not a valid expression
|
||||
*/
|
||||
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROTEXT );
|
||||
if( !bValidMacro )
|
||||
{
|
||||
hb_compErrorMacro( HB_COMP_PARAM, pSelf->value.asString.string );
|
||||
}
|
||||
}
|
||||
HB_EXPR_PCODE1( hb_compGenPCode1, HB_P_MACROTEXT );
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -645,7 +625,7 @@ static HB_EXPR_FUNC( hb_compExprUseArray )
|
||||
switch( iMessage )
|
||||
{
|
||||
case HB_EA_REDUCE:
|
||||
HB_EXPR_PCODE1( hb_compExprReduceList, pSelf );
|
||||
hb_compExprReduceList( pSelf, HB_COMP_PARAM );
|
||||
break;
|
||||
|
||||
case HB_EA_ARRAY_AT:
|
||||
@@ -887,7 +867,7 @@ static HB_EXPR_FUNC( hb_compExprUseIIF )
|
||||
switch( iMessage )
|
||||
{
|
||||
case HB_EA_REDUCE:
|
||||
HB_EXPR_PCODE1( hb_compExprReduceList, pSelf );
|
||||
hb_compExprReduceList( pSelf, HB_COMP_PARAM );
|
||||
pSelf = hb_compExprReduceIIF( pSelf, HB_COMP_PARAM );
|
||||
break;
|
||||
|
||||
@@ -971,7 +951,7 @@ static HB_EXPR_FUNC( hb_compExprUseList )
|
||||
}
|
||||
}
|
||||
|
||||
HB_EXPR_PCODE1( hb_compExprReduceList, pSelf );
|
||||
hb_compExprReduceList( pSelf, HB_COMP_PARAM );
|
||||
/* NOTE: if the list contains a single expression then the list
|
||||
* is not reduced to this expression - if you need that reduction
|
||||
* then call hb_compExprListStrip() additionaly
|
||||
@@ -1081,7 +1061,7 @@ static HB_EXPR_FUNC( hb_compExprUseArgList )
|
||||
switch( iMessage )
|
||||
{
|
||||
case HB_EA_REDUCE:
|
||||
HB_EXPR_PCODE1( hb_compExprReduceList, pSelf );
|
||||
hb_compExprReduceList( pSelf, HB_COMP_PARAM );
|
||||
break;
|
||||
|
||||
case HB_EA_ARRAY_AT:
|
||||
@@ -1145,7 +1125,7 @@ static HB_EXPR_FUNC( hb_compExprUseMacroArgList )
|
||||
switch( iMessage )
|
||||
{
|
||||
case HB_EA_REDUCE:
|
||||
HB_EXPR_PCODE1( hb_compExprReduceList, pSelf );
|
||||
hb_compExprReduceList( pSelf, HB_COMP_PARAM );
|
||||
break;
|
||||
|
||||
case HB_EA_ARRAY_AT:
|
||||
@@ -1401,14 +1381,14 @@ static HB_EXPR_FUNC( hb_compExprUseMacro )
|
||||
* all components should be placed as a string that will
|
||||
* be compiled after text susbstitution
|
||||
*/
|
||||
|
||||
/* Check if macrotext variable does not refer to
|
||||
* local, static or field.
|
||||
*/
|
||||
#if ! defined( HB_MACRO_SUPPORT )
|
||||
BOOL bUseTextSubst;
|
||||
if( !hb_compExprIsValidMacro( pSelf->value.asMacro.szMacro,
|
||||
strlen( pSelf->value.asMacro.szMacro ),
|
||||
&bUseTextSubst, HB_COMP_PARAM ) )
|
||||
{
|
||||
hb_compErrorMacro( HB_COMP_PARAM, pSelf->value.asMacro.szMacro );
|
||||
}
|
||||
hb_compIsValidMacroText( HB_COMP_PARAM,
|
||||
pSelf->value.asMacro.szMacro,
|
||||
strlen( pSelf->value.asMacro.szMacro ) );
|
||||
#endif
|
||||
HB_EXPR_PCODE2( hb_compGenPushString, pSelf->value.asMacro.szMacro, strlen( pSelf->value.asMacro.szMacro ) + 1 );
|
||||
}
|
||||
@@ -1486,15 +1466,15 @@ static HB_EXPR_FUNC( hb_compExprUseMacro )
|
||||
* all components should be placed as a string that will
|
||||
* be compiled after text susbstitution
|
||||
*/
|
||||
|
||||
/* Check if macrotext variable does not refer to
|
||||
* local, static or field.
|
||||
*/
|
||||
#if ! defined( HB_MACRO_SUPPORT )
|
||||
BOOL bUseTextSubst;
|
||||
if( !hb_compExprIsValidMacro( pSelf->value.asMacro.szMacro,
|
||||
strlen( pSelf->value.asMacro.szMacro ),
|
||||
&bUseTextSubst, HB_COMP_PARAM ) )
|
||||
{
|
||||
hb_compErrorMacro( HB_COMP_PARAM, pSelf->value.asMacro.szMacro );
|
||||
}
|
||||
#endif
|
||||
hb_compIsValidMacroText( HB_COMP_PARAM,
|
||||
pSelf->value.asMacro.szMacro,
|
||||
strlen( pSelf->value.asMacro.szMacro ) );
|
||||
#endif
|
||||
HB_EXPR_PCODE2( hb_compGenPushString, pSelf->value.asMacro.szMacro, strlen( pSelf->value.asMacro.szMacro ) + 1 );
|
||||
}
|
||||
}
|
||||
@@ -2014,7 +1994,8 @@ static HB_EXPR_FUNC( hb_compExprUseSend )
|
||||
{
|
||||
case HB_EA_REDUCE:
|
||||
{
|
||||
if( pSelf->value.asMessage.pObject )
|
||||
/* Clipper does not reduce object expressions */
|
||||
if( HB_SUPPORT_HARBOUR && pSelf->value.asMessage.pObject )
|
||||
pSelf->value.asMessage.pObject = hb_compExprListStrip( HB_EXPR_USE( pSelf->value.asMessage.pObject, HB_EA_REDUCE ), HB_COMP_PARAM );
|
||||
if( pSelf->value.asMessage.pParms ) /* Is it a method call ? */
|
||||
pSelf->value.asMessage.pParms = HB_EXPR_USE( pSelf->value.asMessage.pParms, HB_EA_REDUCE );
|
||||
|
||||
@@ -59,11 +59,6 @@
|
||||
until we will not have extended reference items in our HVM [druzus] */
|
||||
/* #define HB_USE_OBJMSG_REF */
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
/* disable warnings for 'no reference to symbol' */
|
||||
#pragma warning 14 9
|
||||
#endif
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
||||
void hb_compExprPushSendPop( HB_EXPR_PTR pSelf, HB_COMP_DECL )
|
||||
@@ -864,7 +859,7 @@ ULONG hb_compExprReduceList( HB_EXPR_PTR pExpr, HB_COMP_DECL )
|
||||
pExpr = pExpr->value.asList.pExprList;
|
||||
while( pExpr )
|
||||
{
|
||||
pNext = pExpr->pNext; /* store next expression in case the current will be reduced */
|
||||
pNext = pExpr->pNext; /* store next expression in case the current will be reduced */
|
||||
pExpr = HB_EXPR_USE( pExpr, HB_EA_REDUCE );
|
||||
*pPrev = pExpr; /* store a new expression into the previous one */
|
||||
pExpr->pNext = pNext; /* restore the link to next expression */
|
||||
@@ -874,99 +869,3 @@ ULONG hb_compExprReduceList( HB_EXPR_PTR pExpr, HB_COMP_DECL )
|
||||
}
|
||||
return ulCnt;
|
||||
}
|
||||
|
||||
BOOL hb_compExprIsValidMacro( char * szText, ULONG ulLen, BOOL *pfUseTextSubst, HB_COMP_DECL )
|
||||
{
|
||||
BOOL fValid = TRUE;
|
||||
|
||||
*pfUseTextSubst = FALSE; /* no valid macro expression */
|
||||
|
||||
while( ulLen-- && fValid )
|
||||
{
|
||||
if( *szText++ == '&' && ulLen )
|
||||
{
|
||||
char ch = *szText;
|
||||
/* Check if macro operator is used inside a string
|
||||
* Macro operator is ignored if it is the last char or
|
||||
* next char is '(' e.g. "this is &(ignored)"
|
||||
* (except if strict Clipper compatibility mode is enabled)
|
||||
*
|
||||
* NOTE: This uses _a-zA-Z pattern to check for
|
||||
* beginning of a variable name
|
||||
*/
|
||||
|
||||
if( ch == '_' || ( ch >= 'A' && ch <= 'Z' ) || ( ch >= 'a' && ch <= 'z' ) )
|
||||
#if defined( HB_MACRO_SUPPORT )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( HB_COMP_PARAM );
|
||||
*pfUseTextSubst = TRUE; /* valid macro expression */
|
||||
return TRUE; /*there is no need to check all '&' occurences */
|
||||
}
|
||||
#else
|
||||
{
|
||||
char szSymName[ HB_SYMBOL_NAME_LEN + 1 ];
|
||||
int iSize = 0;
|
||||
do
|
||||
{
|
||||
if( ch >= 'a' && ch <= 'z' )
|
||||
szSymName[ iSize++ ] = ch - ( 'a' - 'A' );
|
||||
else if( ch == '_' || ( ch >= 'A' && ch <= 'Z' ) ||
|
||||
( ch >= '0' && ch <= '9' ) )
|
||||
szSymName[ iSize++ ] = ch;
|
||||
else
|
||||
break;
|
||||
ch = *(++szText);
|
||||
}
|
||||
while( --ulLen && iSize < HB_SYMBOL_NAME_LEN );
|
||||
szSymName[ iSize ] = '\0';
|
||||
|
||||
/* NOTE: All variables are assumed memvars in macro compiler -
|
||||
* there is no need to check for a valid name but to be Clipper
|
||||
* compatible we should check if local, static or field name
|
||||
* is not use and generate error in such case
|
||||
*/
|
||||
*pfUseTextSubst = TRUE;
|
||||
fValid = hb_compIsValidMacroVar( szSymName, HB_COMP_PARAM );
|
||||
}
|
||||
else if( ! HB_SUPPORT_HARBOUR )
|
||||
*pfUseTextSubst = TRUE; /* always macro substitution in Clipper */
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return fValid;
|
||||
}
|
||||
|
||||
/* Reduces the list of expressions
|
||||
*
|
||||
* pExpr is the first expression on the list
|
||||
*/
|
||||
HB_EXPR_PTR hb_compExprReducePlusStrings( HB_EXPR_PTR pLeft, HB_EXPR_PTR pRight, HB_COMP_DECL )
|
||||
{
|
||||
if( pLeft->value.asString.dealloc )
|
||||
{
|
||||
pLeft->value.asString.string = (char *) hb_xrealloc( pLeft->value.asString.string, pLeft->ulLength + pRight->ulLength + 1 );
|
||||
memcpy( pLeft->value.asString.string + pLeft->ulLength,
|
||||
pRight->value.asString.string, pRight->ulLength );
|
||||
pLeft->ulLength += pRight->ulLength;
|
||||
pLeft->value.asString.string[ pLeft->ulLength ] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
char *szString;
|
||||
szString = (char *) hb_xgrab( pLeft->ulLength + pRight->ulLength + 1 );
|
||||
memcpy( szString, pLeft->value.asString.string, pLeft->ulLength );
|
||||
memcpy( szString + pLeft->ulLength, pRight->value.asString.string, pRight->ulLength );
|
||||
pLeft->ulLength += pRight->ulLength;
|
||||
szString[ pLeft->ulLength ] = '\0';
|
||||
pLeft->value.asString.string = szString;
|
||||
pLeft->value.asString.dealloc = TRUE;
|
||||
}
|
||||
hb_compExprFree( pRight, HB_COMP_PARAM );
|
||||
return pLeft;
|
||||
}
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
/* enable warnings for unreferenced symbols */
|
||||
#pragma warning 14 2
|
||||
#endif
|
||||
|
||||
@@ -133,7 +133,6 @@ extern HB_EXPR_PTR hb_compExprNewFunRef( char *, HB_COMP_DECL );
|
||||
extern HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR, HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern HB_EXPR_PTR hb_compExprNewRef( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern HB_EXPR_PTR hb_compExprNewCodeblockExpr( HB_EXPR_PTR, HB_EXPR_PTR );
|
||||
extern HB_EXPR_PTR hb_compExprNewFunCallArg( HB_EXPR_PTR, HB_EXPR_PTR );
|
||||
extern HB_EXPR_PTR hb_compExprNewSend( HB_EXPR_PTR, char *szMessage, HB_EXPR_PTR pMessage, HB_COMP_DECL );
|
||||
extern HB_EXPR_PTR hb_compExprNewMethodCall( HB_EXPR_PTR, HB_EXPR_PTR );
|
||||
extern HB_EXPR_PTR hb_compExprNewList( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
@@ -144,8 +143,7 @@ extern HB_EXPR_PTR hb_compExprNewArrayAt( HB_EXPR_PTR, HB_EXPR_PTR, HB_COMP_DECL
|
||||
extern HB_EXPR_PTR hb_compExprAddListExpr( HB_EXPR_PTR, HB_EXPR_PTR );
|
||||
extern HB_EXPR_PTR hb_compExprCBVarAdd( HB_EXPR_PTR, char *, BYTE, HB_COMP_DECL );
|
||||
extern HB_EXPR_PTR hb_compExprAddCodeblockExpr( HB_EXPR_PTR, HB_EXPR_PTR );
|
||||
extern HB_EXPR_PTR hb_compExprNewIIF( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern HB_EXPR_PTR hb_compExprReduce( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern HB_EXPR_PTR hb_compExprNewIIF( HB_EXPR_PTR );
|
||||
extern HB_EXPR_PTR hb_compExprMacroAsAlias( HB_EXPR_PTR );
|
||||
extern HB_EXPR_PTR hb_compExprAssign( HB_EXPR_PTR, HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern HB_EXPR_PTR hb_compExprEqual( HB_EXPR_PTR, HB_EXPR_PTR );
|
||||
@@ -163,19 +161,13 @@ extern int hb_compExprIsLong( HB_EXPR_PTR );
|
||||
extern int hb_compExprAsInteger( HB_EXPR_PTR );
|
||||
extern int hb_compExprIsString( HB_EXPR_PTR );
|
||||
extern int hb_compExprAsStringLen( HB_EXPR_PTR );
|
||||
extern char *hb_compExprAsString( HB_EXPR_PTR );
|
||||
extern char *hb_compExprAsSymbol( HB_EXPR_PTR );
|
||||
extern char * hb_compExprAsString( HB_EXPR_PTR );
|
||||
extern char * hb_compExprAsSymbol( HB_EXPR_PTR );
|
||||
|
||||
extern void hb_compExprFree( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern void hb_compExprErrorType( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern HB_EXPR_PTR hb_compExprListStrip( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern void hb_compExprCBVarDel( HB_CBVAR_PTR );
|
||||
extern HB_EXPR_PTR hb_compExprReducePlusStrings( HB_EXPR_PTR, HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern BOOL hb_compExprReduceAT( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern BOOL hb_compExprReduceCHR( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern BOOL hb_compExprReduceLEN( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern BOOL hb_compExprReduceASC( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern BOOL hb_compExprReduceSTOD( HB_EXPR_PTR pSelf, USHORT usCount, HB_COMP_DECL );
|
||||
extern BOOL hb_compExprIsValidMacro( char *, ULONG, BOOL *, HB_COMP_DECL );
|
||||
extern void hb_compExprDelete( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern HB_EXPR_PTR hb_compExprSetOperand( HB_EXPR_PTR, HB_EXPR_PTR, HB_COMP_DECL );
|
||||
@@ -193,6 +185,8 @@ extern void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq, HB_COMP_DECL )
|
||||
extern void hb_compExprPushSendPop( HB_EXPR_PTR pSelf, HB_COMP_DECL );
|
||||
extern void hb_compExprPushSendPush( HB_EXPR_PTR pSelf, HB_COMP_DECL );
|
||||
extern void hb_compExprUseAliasMacro( HB_EXPR_PTR, BYTE, HB_COMP_DECL );
|
||||
|
||||
extern HB_EXPR_PTR hb_compExprReduce( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern ULONG hb_compExprReduceList( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
|
||||
extern HB_EXPR_PTR hb_compExprReduceMod( HB_EXPR_PTR pSelf, HB_COMP_DECL );
|
||||
@@ -211,6 +205,11 @@ extern HB_EXPR_PTR hb_compExprReduceAnd( HB_EXPR_PTR pSelf, HB_COMP_DECL );
|
||||
extern HB_EXPR_PTR hb_compExprReduceOr( HB_EXPR_PTR pSelf, HB_COMP_DECL );
|
||||
extern HB_EXPR_PTR hb_compExprReduceIIF( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
|
||||
extern BOOL hb_compExprReduceAT( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern BOOL hb_compExprReduceCHR( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern BOOL hb_compExprReduceLEN( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern BOOL hb_compExprReduceASC( HB_EXPR_PTR, HB_COMP_DECL );
|
||||
extern BOOL hb_compExprReduceSTOD( HB_EXPR_PTR pSelf, USHORT usCount, HB_COMP_DECL );
|
||||
|
||||
HB_EXTERN_END
|
||||
|
||||
|
||||
@@ -633,10 +633,10 @@ $(PP_DIR)\pptable.c : $(BIN_DIR)\ppgen.exe include\hbstdgen.ch
|
||||
!if "$(HB_REBUILD_PARSER)" == "yes"
|
||||
|
||||
$(OBJ_DIR)\macroy.c : $(MACRO_DIR)\macro.y
|
||||
bison --no-line -p hb_macro -d $** -o$@
|
||||
bison --no-line -d $** -o$@
|
||||
|
||||
$(OBJ_DIR)\harboury.c : $(HARBOUR_DIR)\harbour.y
|
||||
bison --no-line -p hb_comp -d $** -o$@
|
||||
bison --no-line -d $** -o$@
|
||||
|
||||
!else
|
||||
|
||||
@@ -677,10 +677,10 @@ $(OBJ_DIR)\harbourl.obj : $(OBJ_DIR)\harbourl.c
|
||||
!if "$(HB_REBUILD_PARSER)" == "yes"
|
||||
|
||||
$(DLL_OBJ_DIR)\macroy.c : $(MACRO_DIR)\macro.y
|
||||
bison --no-line -p hb_macro -d $** -o$@
|
||||
bison --no-line -d $** -o$@
|
||||
|
||||
$(DLL_OBJ_DIR)\harboury.c : $(HARBOUR_DIR)\harbour.y
|
||||
bison --no-line -p hb_comp -d $** -o$@
|
||||
bison --no-line -d $** -o$@
|
||||
|
||||
!else
|
||||
|
||||
|
||||
@@ -966,10 +966,10 @@ $(PP_DIR)\pptable.c : $(BIN_DIR)\ppgen.exe include\hbstdgen.ch
|
||||
!if "$(HB_REBUILD_PARSER)" == "yes"
|
||||
|
||||
$(OBJ_DIR)\macroy.c : $(MACRO_DIR)\macro.y
|
||||
bison --no-line -p hb_macro -d $** -o$@
|
||||
bison --no-line -d $** -o$@
|
||||
|
||||
$(OBJ_DIR)\harboury.c : $(HARBOUR_DIR)\harbour.y
|
||||
bison --no-line -p hb_comp -d $** -o$@
|
||||
bison --no-line -d $** -o$@
|
||||
|
||||
!else
|
||||
|
||||
@@ -1006,7 +1006,7 @@ $(OBJ_DIR)\harbourl.obj : $(OBJ_DIR)\harbourl.c
|
||||
#**********************************************************
|
||||
|
||||
$(DLL_OBJ_DIR)\macroy.c : $(MACRO_DIR)\macro.y
|
||||
bison --no-line -p hb_macro -d $** -o$@
|
||||
bison --no-line -d $** -o$@
|
||||
|
||||
$(DLL_OBJ_DIR)\macrol.c : $(MACRO_DIR)\macro.l
|
||||
flex -Phb_macro -i -8 -o$@ $**
|
||||
@@ -1020,7 +1020,7 @@ $(DLL_OBJ_DIR)\macrol.obj : $(DLL_OBJ_DIR)\macrol.c
|
||||
#**********************************************************
|
||||
|
||||
$(DLL_OBJ_DIR)\harboury.c : $(HARBOUR_DIR)\harbour.y
|
||||
bison --no-line -p hb_comp -d $** -o$@
|
||||
bison --no-line -d $** -o$@
|
||||
|
||||
$(DLL_OBJ_DIR)\harbourl.c : $(HARBOUR_DIR)\harbour.l
|
||||
flex -Phb_comp -i -8 -o$@ $**
|
||||
|
||||
@@ -487,6 +487,16 @@ HB_EXPR_PTR hb_compExprNewMethodCall( HB_EXPR_PTR pObject, HB_EXPR_PTR pArgList
|
||||
return pObject;
|
||||
}
|
||||
|
||||
/* Create a new IIF() expression
|
||||
* pExpr is a list of three expressions
|
||||
*/
|
||||
HB_EXPR_PTR hb_compExprNewIIF( HB_EXPR_PTR pExpr )
|
||||
{
|
||||
pExpr->ExprType = HB_ET_IIF;
|
||||
|
||||
return pExpr;
|
||||
}
|
||||
|
||||
/* Creates a list - all elements will be used
|
||||
* This list can be used to create an array or function's call arguments
|
||||
*/
|
||||
|
||||
@@ -60,6 +60,31 @@
|
||||
#include "hbcomp.h"
|
||||
#include "hbdate.h"
|
||||
|
||||
static HB_EXPR_PTR hb_compExprReducePlusStrings( HB_EXPR_PTR pLeft, HB_EXPR_PTR pRight, HB_COMP_DECL )
|
||||
{
|
||||
if( pLeft->value.asString.dealloc )
|
||||
{
|
||||
pLeft->value.asString.string = (char *) hb_xrealloc( pLeft->value.asString.string, pLeft->ulLength + pRight->ulLength + 1 );
|
||||
memcpy( pLeft->value.asString.string + pLeft->ulLength,
|
||||
pRight->value.asString.string, pRight->ulLength );
|
||||
pLeft->ulLength += pRight->ulLength;
|
||||
pLeft->value.asString.string[ pLeft->ulLength ] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
char *szString;
|
||||
szString = (char *) hb_xgrab( pLeft->ulLength + pRight->ulLength + 1 );
|
||||
memcpy( szString, pLeft->value.asString.string, pLeft->ulLength );
|
||||
memcpy( szString + pLeft->ulLength, pRight->value.asString.string, pRight->ulLength );
|
||||
pLeft->ulLength += pRight->ulLength;
|
||||
szString[ pLeft->ulLength ] = '\0';
|
||||
pLeft->value.asString.string = szString;
|
||||
pLeft->value.asString.dealloc = TRUE;
|
||||
}
|
||||
hb_compExprFree( pRight, HB_COMP_PARAM );
|
||||
return pLeft;
|
||||
}
|
||||
|
||||
HB_EXPR_PTR hb_compExprReduceMod( HB_EXPR_PTR pSelf, HB_COMP_DECL )
|
||||
{
|
||||
HB_EXPR_PTR pLeft, pRight;
|
||||
@@ -511,10 +536,23 @@ HB_EXPR_PTR hb_compExprReducePlus( HB_EXPR_PTR pSelf, HB_COMP_DECL )
|
||||
{
|
||||
/* Do not reduce strings with the macro operator '&'
|
||||
*/
|
||||
BOOL fSubst;
|
||||
hb_compExprIsValidMacro( pLeft->value.asString.string, pLeft->ulLength,
|
||||
&fSubst, HB_COMP_PARAM );
|
||||
if( !fSubst && pLeft->value.asString.string[ pLeft->ulLength - 1 ] != '&' )
|
||||
char * szText = pLeft->value.asString.string;
|
||||
ULONG ulLen = pLeft->ulLength;
|
||||
BOOL fReduce = TRUE;
|
||||
|
||||
while( ulLen-- )
|
||||
{
|
||||
if( *szText++ == '&' )
|
||||
{
|
||||
char ch = ulLen ? *szText : *pRight->value.asString.string;
|
||||
if( ( ch >= 'A' && ch <= 'Z' ) ||
|
||||
( ch >= 'a' && ch <= 'z' ) || ch == '_' ||
|
||||
! HB_SUPPORT_HARBOUR )
|
||||
fReduce = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if( fReduce )
|
||||
{
|
||||
pSelf->ExprType = HB_ET_NONE; /* suppress deletion of operator components */
|
||||
hb_compExprFree( pSelf, HB_COMP_PARAM );
|
||||
@@ -1184,16 +1222,24 @@ HB_EXPR_PTR hb_compExprReduceIIF( HB_EXPR_PTR pSelf, HB_COMP_DECL )
|
||||
hb_compExprFree( pExpr, HB_COMP_PARAM ); /* delete TRUE expr */
|
||||
pSelf->pNext = NULL;
|
||||
}
|
||||
|
||||
if( pSelf->ExprType == HB_ET_NONE )
|
||||
{
|
||||
pSelf->ExprType = HB_ET_NIL;
|
||||
pSelf->ValType = HB_EV_NIL;
|
||||
}
|
||||
}
|
||||
/* check if valid expression is passed
|
||||
*/
|
||||
else if( ( pExpr->ExprType == HB_ET_DOUBLE ) ||
|
||||
( pExpr->ExprType == HB_ET_LONG ) ||
|
||||
( pExpr->ExprType == HB_ET_NIL ) ||
|
||||
( pExpr->ExprType == HB_ET_STRING ) ||
|
||||
( pExpr->ExprType == HB_ET_CODEBLOCK ) ||
|
||||
( pExpr->ExprType == HB_ET_SELF ) ||
|
||||
( pExpr->ExprType == HB_ET_ARRAY ) )
|
||||
else if( pExpr->ExprType == HB_ET_NIL ||
|
||||
pExpr->ExprType == HB_ET_NUMERIC ||
|
||||
pExpr->ExprType == HB_ET_DATE ||
|
||||
pExpr->ExprType == HB_ET_STRING ||
|
||||
pExpr->ExprType == HB_ET_CODEBLOCK ||
|
||||
pExpr->ExprType == HB_ET_ARRAY ||
|
||||
pExpr->ExprType == HB_ET_VARREF ||
|
||||
pExpr->ExprType == HB_ET_REFERENCE ||
|
||||
pExpr->ExprType == HB_ET_FUNREF )
|
||||
{
|
||||
hb_compExprErrorType( pExpr, HB_COMP_PARAM );
|
||||
}
|
||||
@@ -1214,7 +1260,7 @@ HB_EXPR_PTR hb_compExprListStrip( HB_EXPR_PTR pSelf, HB_COMP_DECL )
|
||||
{
|
||||
/* replace the list with a simple expression
|
||||
* ( EXPR ) -> EXPR
|
||||
*/
|
||||
*/
|
||||
HB_EXPR_PTR pExpr = pSelf;
|
||||
|
||||
pSelf = pSelf->value.asList.pExprList;
|
||||
|
||||
@@ -11,7 +11,7 @@ ROOT = ../../
|
||||
# hberrors.h \
|
||||
# hbdefs.h
|
||||
|
||||
YACC_FLAGS = -p hb_comp
|
||||
#YACC_FLAGS = -p hb_comp
|
||||
YACC_SOURCE=harbour.y
|
||||
YACC_HEADERS=\
|
||||
hbcomp.h \
|
||||
|
||||
@@ -325,14 +325,14 @@ static void hb_compChkEnvironVar( HB_COMP_DECL, char *szSwitch )
|
||||
HB_COMP_PARAM->supported |= HB_COMPFLAG_HB_INLINE;
|
||||
break;
|
||||
|
||||
case 'I':
|
||||
HB_COMP_PARAM->supported |= HB_COMPFLAG_HB_INLINE_PP;
|
||||
break;
|
||||
|
||||
case 'J':
|
||||
HB_COMP_PARAM->supported &= ~HB_COMPFLAG_OPTJUMP;
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
HB_COMP_PARAM->supported &= ~HB_COMPFLAG_MACROTEXT;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
HB_COMP_PARAM->supported |= HB_COMPFLAG_RT_MACRO;
|
||||
break;
|
||||
|
||||
@@ -1072,35 +1072,77 @@ void hb_compGenStaticName( char *szVarName, HB_COMP_DECL )
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate an error if passed variable name cannot be used in macro
|
||||
* expression.
|
||||
* Only MEMVAR or undeclared (memvar will be assumed) variables can be used.
|
||||
/* Check if macrotext variable does not refer to local, static or field.
|
||||
* Only MEMVAR or undeclared (memvar will be assumed) variables can be used
|
||||
* in macro text
|
||||
*/
|
||||
BOOL hb_compIsValidMacroVar( char * szVarName, HB_COMP_DECL )
|
||||
static BOOL hb_compIsValidMacroVar( char * szVarName, HB_COMP_DECL )
|
||||
{
|
||||
BOOL bValid = FALSE;
|
||||
return !hb_compLocalGetPos( HB_COMP_PARAM, szVarName ) &&
|
||||
!hb_compStaticGetPos( szVarName, HB_COMP_PARAM->functions.pLast ) &&
|
||||
!hb_compFieldGetPos( szVarName, HB_COMP_PARAM->functions.pLast ) &&
|
||||
( HB_COMP_PARAM->fStartProc ||
|
||||
hb_compMemvarGetPos( szVarName, HB_COMP_PARAM->functions.pLast ) ||
|
||||
( !hb_compFieldGetPos( szVarName, HB_COMP_PARAM->functions.pFirst ) &&
|
||||
!hb_compStaticGetPos( szVarName, HB_COMP_PARAM->functions.pFirst ) ) );
|
||||
}
|
||||
|
||||
if( hb_compLocalGetPos( HB_COMP_PARAM, szVarName ) )
|
||||
;/* hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_BAD_MACRO, szVarName, NULL );*/
|
||||
else if( hb_compStaticGetPos( szVarName, HB_COMP_PARAM->functions.pLast ) > 0 )
|
||||
;/* hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_BAD_MACRO, szVarName, NULL );*/
|
||||
else if( hb_compFieldGetPos( szVarName, HB_COMP_PARAM->functions.pLast ) > 0 )
|
||||
;/* hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_BAD_MACRO, szVarName, NULL );*/
|
||||
else if( ! HB_COMP_PARAM->fStartProc )
|
||||
BOOL hb_compIsValidMacroText( HB_COMP_DECL, char * szText, ULONG ulLen )
|
||||
{
|
||||
BOOL fFound = FALSE;
|
||||
ULONG ul = 0;
|
||||
|
||||
while( ul < ulLen )
|
||||
{
|
||||
/* Is it a local MEMVAR ? */
|
||||
if( hb_compMemvarGetPos( szVarName, HB_COMP_PARAM->functions.pLast ) )
|
||||
bValid = TRUE;
|
||||
else if( hb_compFieldGetPos( szVarName, HB_COMP_PARAM->functions.pFirst ) > 0 )
|
||||
; /*hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_BAD_MACRO, szVarName, NULL );*/
|
||||
else if( hb_compStaticGetPos( szVarName, HB_COMP_PARAM->functions.pFirst ) > 0 )
|
||||
; /*hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_BAD_MACRO, szVarName, NULL );*/
|
||||
else
|
||||
bValid = TRUE; /* undeclared variable */
|
||||
if( szText[ ul++ ] == '&' )
|
||||
{
|
||||
char szSymName[ HB_SYMBOL_NAME_LEN + 1 ];
|
||||
int iSize = 0;
|
||||
|
||||
/* Check if macro operator is used inside a string
|
||||
* Macro operator is ignored if it is the last char or
|
||||
* next char is '(' e.g. "this is &(ignored)"
|
||||
* (except if strict Clipper compatibility mode is enabled)
|
||||
*
|
||||
* NOTE: This uses _a-zA-Z pattern to check for
|
||||
* beginning of a variable name
|
||||
*/
|
||||
|
||||
while( ul < ulLen && iSize < HB_SYMBOL_NAME_LEN )
|
||||
{
|
||||
char ch = szText[ ul ];
|
||||
if( ch >= 'a' && ch <= 'z' )
|
||||
szSymName[ iSize++ ] = ch - ( 'a' - 'A' );
|
||||
else if( ch == '_' || ( ch >= 'A' && ch <= 'Z' ) ||
|
||||
( ch >= '0' && ch <= '9' ) )
|
||||
szSymName[ iSize++ ] = ch;
|
||||
else
|
||||
break;
|
||||
++ul;
|
||||
}
|
||||
|
||||
if( iSize )
|
||||
{
|
||||
szSymName[ iSize ] = '\0';
|
||||
|
||||
/* NOTE: All variables are assumed memvars in macro compiler -
|
||||
* there is no need to check for a valid name but to be Clipper
|
||||
* compatible we should check if local, static or field name
|
||||
* is not use and generate error in such case
|
||||
*/
|
||||
fFound = TRUE;
|
||||
if( ! hb_compIsValidMacroVar( szSymName, HB_COMP_PARAM ) )
|
||||
{
|
||||
hb_compErrorMacro( HB_COMP_PARAM, szText );
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if( ! HB_SUPPORT_HARBOUR )
|
||||
fFound = TRUE; /* always macro substitution in Clipper */
|
||||
}
|
||||
}
|
||||
else
|
||||
bValid = TRUE; /* undeclared variable */
|
||||
return bValid;
|
||||
|
||||
return fFound;
|
||||
}
|
||||
|
||||
int hb_compVariableScope( HB_COMP_DECL, char * szVarName )
|
||||
@@ -4402,7 +4444,7 @@ static void hb_compInitVars( HB_COMP_DECL )
|
||||
HB_COMP_PARAM->funcalls.pFirst = NULL;
|
||||
HB_COMP_PARAM->funcalls.pLast = NULL;
|
||||
HB_COMP_PARAM->szAnnounce = NULL;
|
||||
HB_COMP_PARAM->fTextSubst = TRUE;
|
||||
HB_COMP_PARAM->fTextSubst = ( HB_COMP_PARAM->supported & HB_COMPFLAG_MACROTEXT ) != 0;
|
||||
HB_COMP_PARAM->fLongOptimize = TRUE;
|
||||
|
||||
HB_COMP_PARAM->symbols.iCount = 0;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
%pure-parser
|
||||
%parse-param { HB_COMP_PTR pComp }
|
||||
%lex-param { HB_COMP_PTR pComp }
|
||||
%name-prefix = "hb_comp"
|
||||
%{
|
||||
/*
|
||||
* $Id$
|
||||
@@ -207,9 +208,9 @@ extern void yyerror( HB_COMP_DECL, char * ); /* parsing error management fun
|
||||
%type <iNumber> Descend
|
||||
%type <lNumber> WhileBegin
|
||||
%type <pVoid> IfElseIf Cases
|
||||
%type <asExpr> Argument ExtArgument ArgList ElemList
|
||||
%type <asExpr> Argument ExtArgument RefArgument ArgList ElemList
|
||||
%type <asExpr> BlockExpList BlockVars BlockVarList
|
||||
%type <asExpr> DoName DoProc DoArgument DoArgList
|
||||
%type <asExpr> DoName DoProc DoArgs DoArgument DoArgList
|
||||
%type <asExpr> PareExpList1 PareExpList2 PareExpList3 PareExpListN
|
||||
%type <asExpr> ExpList ExpList1 ExpList2 ExpList3
|
||||
%type <asExpr> NumValue NumAlias
|
||||
@@ -228,7 +229,7 @@ extern void yyerror( HB_COMP_DECL, char * ); /* parsing error management fun
|
||||
%type <asExpr> FunIdentCall FunCall FunCallAlias FunRef
|
||||
%type <asExpr> ObjectData ObjectDataAlias
|
||||
%type <asExpr> ObjectMethod ObjectMethodAlias
|
||||
%type <asExpr> IfInline IfInlineAlias
|
||||
%type <asExpr> IfInline IfInlineAlias IfExpression
|
||||
%type <asExpr> PareExpList PareExpListAlias
|
||||
%type <asExpr> Expression ExtExpression SimpleExpression LValue LeftExpression
|
||||
%type <asExpr> EmptyExpression
|
||||
@@ -260,7 +261,7 @@ extern void yyerror( HB_COMP_DECL, char * ); /* parsing error management fun
|
||||
|
||||
%%
|
||||
|
||||
Main : { hb_compLinePush( HB_COMP_PARAM ); } Source { }
|
||||
Main : { hb_compLinePush( HB_COMP_PARAM ); } Source { }
|
||||
| /* empty file */
|
||||
;
|
||||
|
||||
@@ -723,17 +724,20 @@ FunRef : '@' FunIdentCall { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, $2
|
||||
FunCallAlias : FunCall ALIASOP
|
||||
;
|
||||
|
||||
ArgList : ExtArgument { $$ = hb_compExprNewArgList( $1, HB_COMP_PARAM ); }
|
||||
| ArgList ',' ExtArgument { $$ = hb_compExprAddListExpr( $1, $3 ); }
|
||||
;
|
||||
ArgList : ExtArgument { $$ = hb_compExprNewArgList( $1, HB_COMP_PARAM ); }
|
||||
| ArgList ',' ExtArgument { $$ = hb_compExprAddListExpr( $1, $3 ); }
|
||||
;
|
||||
|
||||
Argument : EmptyExpression
|
||||
| '@' IdentName { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, hb_compExprNewVarRef( $2, HB_COMP_PARAM ) ); }
|
||||
| '@' MacroVar { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, hb_compExprNewRef( $2, HB_COMP_PARAM ) ); }
|
||||
| '@' AliasVar { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, hb_compExprNewRef( $2, HB_COMP_PARAM ) ); }
|
||||
| '@' ObjectData { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, hb_compExprNewRef( $2, HB_COMP_PARAM ) ); }
|
||||
| '@' VariableAt { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, $2 ); $$->value.asList.reference = TRUE; }
|
||||
;
|
||||
Argument : EmptyExpression
|
||||
| RefArgument
|
||||
;
|
||||
|
||||
RefArgument : '@' IdentName { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, hb_compExprNewVarRef( $2, HB_COMP_PARAM ) ); }
|
||||
| '@' MacroVar { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, hb_compExprNewRef( $2, HB_COMP_PARAM ) ); }
|
||||
| '@' AliasVar { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, hb_compExprNewRef( $2, HB_COMP_PARAM ) ); }
|
||||
| '@' ObjectData { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, hb_compExprNewRef( $2, HB_COMP_PARAM ) ); }
|
||||
| '@' VariableAt { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, $2 ); $$->value.asList.reference = TRUE; }
|
||||
;
|
||||
|
||||
ExtArgument : EPSILON { $$ = hb_compExprNewArgRef( HB_COMP_PARAM ); }
|
||||
| Argument
|
||||
@@ -872,11 +876,6 @@ ExprUnary : NOT Expression { $$ = hb_compExprNewNot( $2, HB_CO
|
||||
| '+' Expression %prec UNARY { $$ = $2; }
|
||||
;
|
||||
|
||||
/*
|
||||
ExprAssign : Expression INASSIGN Expression { $$ = hb_compExprAssign( $1, $3, HB_COMP_PARAM ); }
|
||||
;
|
||||
*/
|
||||
|
||||
ExprAssign : NumValue INASSIGN Expression { $$ = hb_compExprAssign( $1, $3, HB_COMP_PARAM ); }
|
||||
| NilValue INASSIGN Expression { $$ = hb_compExprAssign( $1, $3, HB_COMP_PARAM ); }
|
||||
| DateValue INASSIGN Expression { $$ = hb_compExprAssign( $1, $3, HB_COMP_PARAM ); }
|
||||
@@ -1016,24 +1015,33 @@ PareExpList : PareExpList1
|
||||
PareExpListAlias : PareExpList ALIASOP
|
||||
;
|
||||
|
||||
ExpList1 : '(' Argument { $$ = hb_compExprNewList( $2, HB_COMP_PARAM ); }
|
||||
;
|
||||
/* NOTE: Clipper allows to pass variable by reference only as
|
||||
* function argument, IIF() 2-nd and 3-rd argument and as
|
||||
* explicit array item {...@var...}
|
||||
* AFAIK these are also the only one places where empty expressions in
|
||||
* the parenthesis expressions list are accepted
|
||||
*/
|
||||
ExpList1 : '(' Expression { $$ = hb_compExprNewList( $2, HB_COMP_PARAM ); }
|
||||
;
|
||||
|
||||
ExpList2 : ExpList1 ',' Argument { $$ = hb_compExprAddListExpr( $1, $3 ); }
|
||||
;
|
||||
ExpList2 : ExpList1 ',' Expression { $$ = hb_compExprAddListExpr( $1, $3 ); }
|
||||
;
|
||||
|
||||
ExpList3 : ExpList2 ',' Argument { $$ = hb_compExprAddListExpr( $1, $3 ); }
|
||||
;
|
||||
ExpList3 : ExpList2 ',' Expression { $$ = hb_compExprAddListExpr( $1, $3 ); }
|
||||
;
|
||||
|
||||
ExpList : ExpList3 ',' Argument { $$ = hb_compExprAddListExpr( $1, $3 ); }
|
||||
| ExpList ',' Argument { $$ = hb_compExprAddListExpr( $1, $3 ); }
|
||||
;
|
||||
ExpList : ExpList3 ',' Expression { $$ = hb_compExprAddListExpr( $1, $3 ); }
|
||||
| ExpList ',' Expression { $$ = hb_compExprAddListExpr( $1, $3 ); }
|
||||
;
|
||||
|
||||
IfInline : IIF PareExpList3 { $$ = hb_compExprNewIIF( $2, HB_COMP_PARAM ); }
|
||||
| IF ExpList1 ',' Argument ','
|
||||
{ $<asExpr>$ = hb_compExprAddListExpr( $2, $4 ); }
|
||||
Argument ')'
|
||||
{ $$ = hb_compExprNewIIF( hb_compExprAddListExpr( $<asExpr>6, $7 ), HB_COMP_PARAM ); }
|
||||
IfInline : IIF '(' Expression ',' Argument ',' Argument ')'
|
||||
{ $$ = hb_compExprNewIIF( hb_compExprAddListExpr( hb_compExprAddListExpr( hb_compExprNewList( $3, HB_COMP_PARAM ), $5 ), $7 ) ); }
|
||||
| IF ExpList1 ',' Expression ',' Argument ')'
|
||||
{ $$ = hb_compExprNewIIF( hb_compExprAddListExpr( hb_compExprAddListExpr( hb_compExprNewList( $2, HB_COMP_PARAM ), $4 ), $6 ) ); }
|
||||
| IF ExpList1 ',' RefArgument ',' Argument ')'
|
||||
{ $$ = hb_compExprNewIIF( hb_compExprAddListExpr( hb_compExprAddListExpr( hb_compExprNewList( $2, HB_COMP_PARAM ), $4 ), $6 ) ); }
|
||||
| IF ExpList1 ',' ',' Argument ')'
|
||||
{ $$ = hb_compExprNewIIF( hb_compExprAddListExpr( hb_compExprAddListExpr( hb_compExprNewList( $2, HB_COMP_PARAM ), hb_compExprNewEmpty( HB_COMP_PARAM ) ), $5 ) ); }
|
||||
;
|
||||
|
||||
IfInlineAlias : IfInline ALIASOP
|
||||
@@ -1328,27 +1336,21 @@ EmptyStats : /* empty */ { $<lNumber>$ = 0; }
|
||||
| EmptyStatements { $<lNumber>$ = $<lNumber>1; }
|
||||
;
|
||||
|
||||
IfBegin : IF SimpleExpression { ++HB_COMP_PARAM->wIfCounter; hb_compLinePushIfInside( HB_COMP_PARAM ); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); }
|
||||
EmptyStats
|
||||
{ $$ = hb_compGenJump( 0, HB_COMP_PARAM ); hb_compGenJumpHere( $<iNumber>5, HB_COMP_PARAM ); }
|
||||
|
||||
| IF Variable { ++HB_COMP_PARAM->wIfCounter; hb_compLinePushIfInside( HB_COMP_PARAM ); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); }
|
||||
EmptyStats
|
||||
{ $$ = hb_compGenJump( 0, HB_COMP_PARAM ); hb_compGenJumpHere( $<iNumber>5, HB_COMP_PARAM ); }
|
||||
|
||||
| IF PareExpList1 { ++HB_COMP_PARAM->wIfCounter; hb_compLinePushIfInside( HB_COMP_PARAM ); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); }
|
||||
EmptyStats
|
||||
{ $$ = hb_compGenJump( 0, HB_COMP_PARAM ); hb_compGenJumpHere( $<iNumber>5, HB_COMP_PARAM ); }
|
||||
|
||||
| IF PareExpList2 { ++HB_COMP_PARAM->wIfCounter; hb_compLinePushIfInside( HB_COMP_PARAM ); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); }
|
||||
EmptyStats
|
||||
{ $$ = hb_compGenJump( 0, HB_COMP_PARAM ); hb_compGenJumpHere( $<iNumber>5, HB_COMP_PARAM ); }
|
||||
|
||||
| IF PareExpListN { ++HB_COMP_PARAM->wIfCounter; hb_compLinePushIfInside( HB_COMP_PARAM ); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); }
|
||||
EmptyStats
|
||||
{ $$ = hb_compGenJump( 0, HB_COMP_PARAM ); hb_compGenJumpHere( $<iNumber>5, HB_COMP_PARAM ); }
|
||||
IfBegin : IF IfExpression
|
||||
{ ++HB_COMP_PARAM->wIfCounter; hb_compLinePushIfInside( HB_COMP_PARAM ); }
|
||||
Crlf
|
||||
{ hb_compExprDelete( hb_compExprGenPush( $2, HB_COMP_PARAM ), HB_COMP_PARAM ); $$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM ); }
|
||||
EmptyStats
|
||||
{ $$ = hb_compGenJump( 0, HB_COMP_PARAM ); hb_compGenJumpHere( $<iNumber>5, HB_COMP_PARAM ); }
|
||||
;
|
||||
|
||||
IfExpression: SimpleExpression
|
||||
| Variable
|
||||
| PareExpList1
|
||||
| PareExpList2
|
||||
| PareExpListN
|
||||
;
|
||||
|
||||
IfElse : ELSE Crlf { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; }
|
||||
EmptyStats
|
||||
;
|
||||
@@ -1589,7 +1591,7 @@ ForStatements : EmptyStats NEXT { hb_compLinePush( HB_COMP_P
|
||||
ForVar : IdentName { $$ = hb_compExprNewVarRef( $1, HB_COMP_PARAM ); }
|
||||
| AliasVar { $$ = hb_compExprNewRef( $1, HB_COMP_PARAM ); }
|
||||
;
|
||||
|
||||
|
||||
ForList : ForVar { $$ = hb_compExprNewArgList( $1, HB_COMP_PARAM ); }
|
||||
| ForList ',' ForVar { $$ = hb_compExprAddListExpr( $1, $3 ); }
|
||||
;
|
||||
@@ -1597,7 +1599,7 @@ ForList : ForVar { $$ = hb_compExprNewArgList( $1, HB_COMP_PAR
|
||||
ForExpr : Expression { $$ = hb_compExprNewArgList( $1, HB_COMP_PARAM ); }
|
||||
| ForExpr ',' Expression { $$ = hb_compExprAddListExpr( $1, $3 ); }
|
||||
;
|
||||
|
||||
|
||||
ForEach : FOREACH ForList IN ForExpr /* 1 2 3 4 */
|
||||
{
|
||||
++HB_COMP_PARAM->wForCounter; /* 5 */
|
||||
@@ -1657,7 +1659,7 @@ DoSwitch : SwitchBegin
|
||||
hb_compGenPCode1( HB_P_POP, HB_COMP_PARAM );
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
EndSwitch : END
|
||||
{ if( HB_COMP_PARAM->wSwitchCounter )
|
||||
--HB_COMP_PARAM->wSwitchCounter;
|
||||
@@ -1698,7 +1700,7 @@ SwitchCases : CASE Expression { hb_compSwitchAdd( HB_COMP_PARAM, $2 ); hb_compLi
|
||||
SwitchDefault : OTHERWISE { hb_compSwitchAdd( HB_COMP_PARAM, NULL ); hb_compLinePush( HB_COMP_PARAM ); } Crlf { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; }
|
||||
EmptyStats
|
||||
;
|
||||
|
||||
|
||||
BeginSeq : BEGINSEQ
|
||||
{
|
||||
++HB_COMP_PARAM->wSeqCounter;
|
||||
@@ -1770,25 +1772,30 @@ RecoverUsing : RECOVERUSING IdentName
|
||||
* DO .. WITH ++variable
|
||||
* will pass the value of variable not a reference
|
||||
*/
|
||||
DoName : IdentName { $$ = hb_compExprNewFunName( $1, HB_COMP_PARAM ); hb_compAutoOpenAdd( HB_COMP_PARAM, $1 ); }
|
||||
| MacroVar
|
||||
DoName : MacroVar
|
||||
| MacroExpr
|
||||
;
|
||||
|
||||
DoProc : DO DoName
|
||||
{ $$ = hb_compExprNewFunCall( $2, NULL, HB_COMP_PARAM ); }
|
||||
| DO DoName WITH DoArgList
|
||||
{ $$ = hb_compExprNewFunCall( $2, $4, HB_COMP_PARAM ); }
|
||||
| DOIDENT
|
||||
{
|
||||
/* DOIDENT is the only one identifier which can be returned in lower letters */
|
||||
hb_compAutoOpenAdd( HB_COMP_PARAM, $1 ); $$ = hb_compExprNewFunCall( hb_compExprNewFunName( hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( hb_strdup( $1 ) ), HB_IDENT_FREE ), HB_COMP_PARAM ), NULL, HB_COMP_PARAM );
|
||||
}
|
||||
| DOIDENT WITH DoArgList
|
||||
{ $<bTrue>$ = HB_COMP_PARAM->iPassByRef;HB_COMP_PARAM->iPassByRef=HB_PASSBYREF_FUNCALL; }
|
||||
DoArgs
|
||||
{
|
||||
/* DOIDENT is the only one identifier which can be returned in lower letters */
|
||||
hb_compAutoOpenAdd( HB_COMP_PARAM, $1 ); $$ = hb_compExprNewFunCall( hb_compExprNewFunName( hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( hb_strdup( $1 ) ), HB_IDENT_FREE ), HB_COMP_PARAM ), $3, HB_COMP_PARAM );
|
||||
$$ = hb_compExprNewFunCall( $2, $4, HB_COMP_PARAM );
|
||||
HB_COMP_PARAM->iPassByRef = $<bTrue>3;
|
||||
}
|
||||
| DOIDENT
|
||||
{ $<bTrue>$ = HB_COMP_PARAM->iPassByRef;HB_COMP_PARAM->iPassByRef=HB_PASSBYREF_FUNCALL; }
|
||||
DoArgs
|
||||
{
|
||||
hb_compAutoOpenAdd( HB_COMP_PARAM, $1 );
|
||||
/* DOIDENT is the only one identifier which can be returned in lower letters */
|
||||
$$ = hb_compExprNewFunCall( hb_compExprNewFunName( hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( hb_strdup( $1 ) ), HB_IDENT_FREE ), HB_COMP_PARAM ), $3, HB_COMP_PARAM );
|
||||
HB_COMP_PARAM->iPassByRef = $<bTrue>2;
|
||||
}
|
||||
;
|
||||
|
||||
DoArgs : /* empty */ { $$ = NULL; }
|
||||
| WITH DoArgList { $$ = $2; }
|
||||
;
|
||||
|
||||
DoArgList : ',' { $$ = hb_compExprAddListExpr( hb_compExprNewArgList( hb_compExprNewNil( HB_COMP_PARAM ), HB_COMP_PARAM ), hb_compExprNewNil( HB_COMP_PARAM ) ); }
|
||||
@@ -1799,11 +1806,7 @@ DoArgList : ',' { $$ = hb_compExprAddListExpr( hb_compExp
|
||||
;
|
||||
|
||||
DoArgument : IdentName { $$ = hb_compExprNewVarRef( $1, HB_COMP_PARAM ); }
|
||||
| '@' IdentName { $$ = hb_compExprNewVarRef( $2, HB_COMP_PARAM ); }
|
||||
| '@' MacroVar { $$ = hb_compExprNewRef( $2, HB_COMP_PARAM ); }
|
||||
| '@' AliasVar { $$ = hb_compExprNewRef( $2, HB_COMP_PARAM ); }
|
||||
| '@' ObjectData { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, hb_compExprNewRef( $2, HB_COMP_PARAM ) ); }
|
||||
| '@' VariableAt { $$ = hb_compCheckPassByRef( HB_COMP_PARAM, $2 ); $$->value.asList.reference = TRUE; }
|
||||
| RefArgument
|
||||
| FunRef
|
||||
| SimpleExpression
|
||||
| PareExpList
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -250,7 +250,7 @@
|
||||
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
#line 103 "harbour.y"
|
||||
#line 104 "harbour.y"
|
||||
{
|
||||
char * string; /* to hold a string returned by lex */
|
||||
int iNumber; /* to hold a temporary integer number */
|
||||
|
||||
@@ -76,10 +76,11 @@ HB_COMP_PTR hb_comp_new( void )
|
||||
HB_COMPFLAG_XBASE |
|
||||
HB_COMPFLAG_HB_INLINE |
|
||||
HB_COMPFLAG_OPTJUMP |
|
||||
HB_COMPFLAG_MACROTEXT |
|
||||
HB_COMPFLAG_SHORTCUTS;
|
||||
|
||||
pComp->fTextSubst = pComp->fLongOptimize = TRUE;
|
||||
|
||||
pComp->fTextSubst = ( pComp->supported & HB_COMPFLAG_MACROTEXT ) != 0;
|
||||
pComp->fLongOptimize = TRUE;
|
||||
pComp->fPPO = FALSE; /* flag indicating, is ppo output needed */
|
||||
pComp->fStartProc = TRUE; /* holds if we need to create the starting procedure */
|
||||
pComp->fLineNumbers = TRUE; /* holds if we need pcodes with line numbers */
|
||||
|
||||
@@ -120,11 +120,11 @@ void hb_compPrintModes( void )
|
||||
"\nOptions: c clear all flags (strict Clipper mode)",
|
||||
"\n h Harbour mode (default)",
|
||||
"\n i enable support for HB_INLINE",
|
||||
"\n I enable support for HB_INLINE in PP",
|
||||
"\n r runtime settings enabled",
|
||||
"\n s string as bytes array enabled",
|
||||
"\n x extended xbase mode",
|
||||
"\n J turn off jump optimization in pcode",
|
||||
"\n M turn off macrotext substitution",
|
||||
"\n ? this info",
|
||||
"\n"
|
||||
};
|
||||
|
||||
@@ -174,7 +174,7 @@ void hb_compInitPP( HB_COMP_DECL, int argc, char * argv[] )
|
||||
HB_COMP_PARAM->iMaxTransCycles,
|
||||
HB_COMP_PARAM, NULL, NULL,
|
||||
hb_pp_ErrorGen, NULL, hb_pp_PragmaDump,
|
||||
HB_COMP_ISSUPPORTED( HB_COMPFLAG_HB_INLINE_PP ) ?
|
||||
HB_COMP_ISSUPPORTED( HB_COMPFLAG_HB_INLINE ) ?
|
||||
hb_pp_hb_inLine : NULL, hb_pp_CompilerSwitch );
|
||||
|
||||
if( ! HB_COMP_PARAM->szStdCh )
|
||||
|
||||
@@ -21,7 +21,7 @@ ROOT = ../../
|
||||
# hbdefs.h \
|
||||
# hbmacro.h \
|
||||
|
||||
YACC_FLAGS = -p hb_macro
|
||||
#YACC_FLAGS = -p hb_macro
|
||||
YACC_SOURCE=macro.y
|
||||
YACC_HEADERS=\
|
||||
hbmacro.h \
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
%pure-parser
|
||||
%parse-param { HB_MACRO_PTR pMacro }
|
||||
%lex-param { HB_MACRO_PTR pMacro }
|
||||
%name-prefix = "hb_macro"
|
||||
|
||||
%{
|
||||
/*
|
||||
@@ -686,10 +687,8 @@ PareExpListAlias : PareExpList ALIASOP
|
||||
;
|
||||
|
||||
/* Lexer should return IIF for "if" symbol */
|
||||
IfInline : IIF '(' Expression ',' EmptyExpression ','
|
||||
{ $<asExpr>$ = hb_compExprAddListExpr( hb_compExprNewList( $3, HB_COMP_PARAM ), $5 ); }
|
||||
EmptyExpression ')'
|
||||
{ $$ = hb_compExprNewIIF( hb_compExprAddListExpr( $<asExpr>7, $8 ), HB_COMP_PARAM ); }
|
||||
IfInline : IIF '(' Expression ',' Argument ',' Argument ')'
|
||||
{ $$ = hb_compExprNewIIF( hb_compExprAddListExpr( hb_compExprAddListExpr( hb_compExprNewList( $3, HB_COMP_PARAM ), $5 ), $7 ) ); }
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -120,7 +120,7 @@
|
||||
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
#line 120 "macro.y"
|
||||
#line 121 "macro.y"
|
||||
{
|
||||
char * string; /* to hold a string returned by lex */
|
||||
int iNumber; /* to hold a temporary integer number */
|
||||
|
||||
@@ -955,6 +955,26 @@ int hb_compLocalVarGetPos( char * szVarName, HB_COMP_DECL )
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL hb_compIsValidMacroText( HB_COMP_DECL, char * szText, ULONG ulLen )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( HB_COMP_PARAM );
|
||||
|
||||
if( ulLen )
|
||||
{
|
||||
while( --ulLen )
|
||||
{
|
||||
if( *szText++ == '&' )
|
||||
{
|
||||
char ch = *szText;
|
||||
if( ( ch >= 'A' && ch <= 'Z' ) ||
|
||||
( ch >= 'a' && ch <= 'z' ) || ch == '_' )
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ULONG hb_compGenJump( LONG lOffset, HB_COMP_DECL )
|
||||
{
|
||||
|
||||
@@ -549,7 +549,7 @@ void hb_memvarNewParameter( PHB_SYMB pSymbol, PHB_ITEM pValue )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_memvarNewParameter(%p, %p)", pSymbol, pValue));
|
||||
|
||||
hb_memvarCreateFromDynSymbol( pSymbol->pDynSym, HB_MV_PRIVATE, pValue );
|
||||
hb_memvarCreateFromDynSymbol( pSymbol->pDynSym, VS_PRIVATE, pValue );
|
||||
}
|
||||
|
||||
static HB_DYNS_PTR hb_memvarFindSymbol( char * szArg, ULONG ulLen )
|
||||
@@ -558,7 +558,7 @@ static HB_DYNS_PTR hb_memvarFindSymbol( char * szArg, ULONG ulLen )
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_memvarFindSymbol(%p,%lu)", szArg, ulLen));
|
||||
|
||||
if( szArg && *szArg && ulLen )
|
||||
if( ulLen && szArg && *szArg )
|
||||
{
|
||||
char szUprName[ HB_SYMBOL_NAME_LEN + 1 ];
|
||||
int iSize = 0;
|
||||
@@ -653,11 +653,11 @@ void hb_memvarCreateFromItem( PHB_ITEM pMemvar, BYTE bScope, PHB_ITEM pValue )
|
||||
pDynVar = pMemvar->item.asSymbol.value->pDynSym;
|
||||
else if( HB_IS_STRING( pMemvar ) )
|
||||
pDynVar = hb_dynsymGet( pMemvar->item.asString.value );
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 3008, NULL, "&", HB_ERR_ARGS_BASEPARAMS );
|
||||
|
||||
if( pDynVar )
|
||||
hb_memvarCreateFromDynSymbol( pDynVar, bScope, pValue );
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 3008, NULL, "&", HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
static void hb_memvarCreateFromDynSymbol( PHB_DYNS pDynVar, BYTE bScope, PHB_ITEM pValue )
|
||||
@@ -1070,7 +1070,8 @@ HB_FUNC( __MVSCOPE )
|
||||
PHB_ITEM pVarName = hb_param( 1, HB_IT_STRING );
|
||||
|
||||
if( pVarName )
|
||||
iMemvar = hb_memvarScope( pVarName->item.asString.value, pVarName->item.asString.length + 1 );
|
||||
iMemvar = hb_memvarScope( pVarName->item.asString.value,
|
||||
pVarName->item.asString.length );
|
||||
}
|
||||
|
||||
hb_retni( iMemvar );
|
||||
|
||||
@@ -50,11 +50,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hbvmopt.h"
|
||||
#include "hbapi.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbcomp.h" /* for VS_* macros */
|
||||
|
||||
HB_FUNC_EXTERN( __MVPUBLIC );
|
||||
HB_FUNC_EXTERN( __MVCLEAR );
|
||||
HB_FUNC_EXTERN( __MVRELEASE );
|
||||
HB_FUNC_EXTERN( __MVXRELEASE );
|
||||
@@ -67,10 +65,15 @@ HB_FUNC_EXTERN( __MVRESTORE );
|
||||
|
||||
HB_FUNC( __QQPUB )
|
||||
{
|
||||
PHB_ITEM pItem = hb_param( 1, HB_IT_STRING );
|
||||
|
||||
if( pItem )
|
||||
hb_memvarCreateFromItem( pItem, VS_PUBLIC, NULL );
|
||||
if( hb_pcount() == 1 )
|
||||
{
|
||||
/* In Clipper __QQPUB function does not check number of parameters
|
||||
or parameter type - just simply takes directly the top item from
|
||||
VM stack */
|
||||
PHB_ITEM pItem = hb_param( 1, HB_IT_STRING );
|
||||
if( pItem )
|
||||
HB_FUNC_EXEC( __MVPUBLIC );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -79,25 +82,25 @@ HB_FUNC( __QQPUB )
|
||||
|
||||
HB_FUNC( __MCLEAR )
|
||||
{
|
||||
HB_FUNCNAME( __MVCLEAR )();
|
||||
HB_FUNC_EXEC( __MVCLEAR );
|
||||
}
|
||||
|
||||
HB_FUNC( __MRELEASE )
|
||||
{
|
||||
HB_FUNCNAME( __MVRELEASE )();
|
||||
HB_FUNC_EXEC( __MVRELEASE );
|
||||
}
|
||||
|
||||
HB_FUNC( __MXRELEASE )
|
||||
{
|
||||
HB_FUNCNAME( __MVXRELEASE )();
|
||||
HB_FUNC_EXEC( __MVXRELEASE );
|
||||
}
|
||||
|
||||
HB_FUNC( __MSAVE )
|
||||
{
|
||||
HB_FUNCNAME( __MVSAVE )();
|
||||
HB_FUNC_EXEC( __MVSAVE );
|
||||
}
|
||||
|
||||
HB_FUNC( __MRESTORE )
|
||||
{
|
||||
HB_FUNCNAME( __MVRESTORE )();
|
||||
HB_FUNC_EXEC( __MVRESTORE );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user