diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e2e64bb050..8650060526 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,19 @@ +2000-11-02 20:35 UTC+0800 Ron Pinkas + * source/compiler/harbour.sly + + Added rule to accept Get and GetA as FunCall + + * source/compiler/harbour.y + + Added support for pseudo function _GET_() + * source/compiler/harbour.l + + Added _GET_(...) => __GET(...)/__GETA(...) logic from harbour.sly + + * source/macro/macro.slx + * Corrected YY_DECL #define (Thanks John) + + * source/rtl/tget.prg + * include/hbextern.ch + - Removed no longer needed _GET_() + 2000-11-03 22:30 UTC+0100 (for) Charles,Kwon * source/lang/msgko.c Charles,Kwon update as requested ... diff --git a/harbour/include/hbextern.ch b/harbour/include/hbextern.ch index 1a3faf5946..d7ca321605 100644 --- a/harbour/include/hbextern.ch +++ b/harbour/include/hbextern.ch @@ -694,7 +694,6 @@ EXTERNAL __TEXTRESTORE //symbols from file: rtl\tget.prg // EXTERNAL GETNEW -EXTERNAL _GET_ EXTERNAL __GET EXTERNAL __GETA // diff --git a/harbour/source/compiler/harbour.l b/harbour/source/compiler/harbour.l index 3b0a7d5acf..891a40daef 100644 --- a/harbour/source/compiler/harbour.l +++ b/harbour/source/compiler/harbour.l @@ -456,6 +456,18 @@ Separator {SpaceTab} /* ************************************************************************ */ %} +%{ +/* ************************************************************************ */ +%} +"_get_(" { + yylval.string = hb_compIdentifierNew( "_PROCREQ_", TRUE ); + hb_comp_iState =IDENTIFIER; + return GET; + } +%{ +/* ************************************************************************ */ +%} + "decl"|"decla"|"declar"|"declare" { yylval.string = hb_compIdentifierNew( hb_strupr( yytext ), TRUE ); if( hb_comp_iState == DO ) diff --git a/harbour/source/compiler/harbour.sly b/harbour/source/compiler/harbour.sly index 7702f9b74f..059e1d81d4 100644 --- a/harbour/source/compiler/harbour.sly +++ b/harbour/source/compiler/harbour.sly @@ -611,6 +611,8 @@ VariableAtAlias : VariableAt ALIASOP { $$ = $1; } */ FunCall : IdentName '(' ArgList ')' { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( $1 ), $3 ); } | MacroVar '(' ArgList ')' { $$ = hb_compExprNewFunCall( $1, $3 ); } + | Get { $$ = $1 } + | GetA { $$ = $1 } ; ArgList : Argument { $$ = hb_compExprNewArgList( $1 ); } @@ -645,8 +647,6 @@ ObjectData : NumValue ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } | MacroVar ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } | MacroExpr ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } | FunCall ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | Get ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | GetA ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } | IfInline ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } | PareExpList ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } | VariableAt ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index 2eaee6b43b..7bd2ce31eb 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -117,6 +117,9 @@ char * hb_comp_buffer; /* yacc input buffer */ static PTR_LOOPEXIT hb_comp_pLoops = NULL; static HB_RTVAR_PTR hb_comp_rtvars = NULL; +static HB_EXPR_PTR pArrayIndexAsList = NULL, pGetArgList = NULL, pBaseArrayName = NULL; +static BOOL bTrancuateBaseArray = FALSE; + char * hb_comp_szAnnounce = NULL; /* ANNOUNCEd procedure */ static void hb_compDebugStart( void ) { }; @@ -160,7 +163,7 @@ static void hb_compDebugStart( void ) { }; %token MACROVAR MACROTEXT %token AS_ARRAY AS_BLOCK AS_CHARACTER AS_CLASS AS_DATE AS_LOGICAL AS_NUMERIC AS_OBJECT AS_VARIANT DECLARE OPTIONAL DECLARE_CLASS DECLARE_MEMBER %token AS_ARRAY_ARRAY AS_BLOCK_ARRAY AS_CHARACTER_ARRAY AS_CLASS_ARRAY AS_DATE_ARRAY AS_LOGICAL_ARRAY AS_NUMERIC_ARRAY AS_OBJECT_ARRAY -%token PROCREQ +%token PROCREQ GET /*the lowest precedence*/ /*postincrement and postdecrement*/ @@ -229,6 +232,7 @@ static void hb_compDebugStart( void ) { }; %type DimIndex DimList %type FieldAlias FieldVarAlias %type PostOp +%type Get GetA GetArgList %% @@ -453,8 +457,17 @@ NilAlias : NilValue ALIASOP { $$ = $1; } /* Literal string value */ -LiteralValue : LITERAL { $$ = hb_compExprNewString( $1 ); } -; +LiteralValue : LITERAL { $$ = hb_compExprNewString( $1 ); + if( bTrancuateBaseArray ) + { char *pCopy = hb_strdup( $1 ), *pTmp = strchr( pCopy, '[' ); + if( pTmp ) + { + pCopy[ pTmp - pCopy ] = '\0'; + pBaseArrayName = hb_compExprNewString( pCopy ); + } + bTrancuateBaseArray = FALSE; +; } + } LiteralAlias : LiteralValue ALIASOP { $$ = $1; } ; @@ -613,6 +626,8 @@ VariableAtAlias : VariableAt ALIASOP { $$ = $1; } */ FunCall : IdentName '(' ArgList ')' { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( $1 ), $3 ); } | MacroVar '(' ArgList ')' { $$ = hb_compExprNewFunCall( $1, $3 ); } + | Get { $$ = $1 } + | GetA { $$ = $1 } ; ArgList : Argument { $$ = hb_compExprNewArgList( $1 ); } @@ -971,9 +986,9 @@ ArrayIndex : IndexList ']' { $$ = $1; } /* NOTE: $0 represents the expression before ArrayIndex * Don't use ArrayIndex in other context than as an array index! */ -IndexList : '[' Expression { $$ = hb_compExprNewArrayAt( $0, $2 ); } - | IndexList ',' Expression { $$ = hb_compExprNewArrayAt( $1, $3 ); } - | IndexList ']' '[' Expression { $$ = hb_compExprNewArrayAt( $1, $4 ); } +IndexList : '[' Expression { $$ = hb_compExprNewArrayAt( $0, $2 ); pArrayIndexAsList = hb_compExprNewList( $2 ); } + | IndexList ',' Expression { $$ = hb_compExprNewArrayAt( $1, $3 ) ; pArrayIndexAsList = hb_compExprAddListExpr( pArrayIndexAsList, $3 ); } + | IndexList ']' '[' Expression { $$ = hb_compExprNewArrayAt( $1, $4 ) ; pArrayIndexAsList = hb_compExprAddListExpr( pArrayIndexAsList, $4 ); } ; ElemList : Argument { $$ = hb_compExprNewList( $1 ); } @@ -986,6 +1001,58 @@ CodeBlock : '{' '|' { $$ = hb_compExprNewCodeBlock(); } BlockNoVar '|' BlockExpList '}' { $$ = $3; } ; +Get : GET Variable { pGetArgList = hb_compExprNewArgList( $2 ); } ',' GetArgList ')' + { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GET"), pGetArgList ); pGetArgList = NULL; } + | GET AliasVar { pGetArgList = hb_compExprNewArgList( $2 ); } ',' GetArgList ')' + { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GET"), pGetArgList ); pGetArgList = NULL; } + | GET ObjectData { pGetArgList = hb_compExprNewArgList( $2 ); } ',' GetArgList ')' + { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GET"), pGetArgList ); pGetArgList = NULL; } + | GET ObjectData ArrayIndex { pGetArgList = hb_compExprNewArgList( $3 ); } ',' GetArgList ')' + { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GET"), pGetArgList ); pGetArgList = NULL; } + | GET MacroVar { pGetArgList = hb_compExprNewArgList( $2 ); } ',' GetArgList ')' + { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GET"), pGetArgList ); pGetArgList = NULL; } + | GET MacroExpr { pGetArgList = hb_compExprNewArgList( $2 ); } ',' GetArgList ')' + { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GET"), pGetArgList ); pGetArgList = NULL; } + ; + +GetArgList : Argument { $$ = hb_compExprAddListExpr( pGetArgList, $1 ); } + | GetArgList ',' Argument { $$ = hb_compExprAddListExpr( pGetArgList, $3 ); } + ; + +GetA : GET Variable ArrayIndex { pGetArgList = hb_compExprNewArgList( $2 ); bTrancuateBaseArray = TRUE; } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, ( pBaseArrayName ? pBaseArrayName : $6 ) ); pBaseArrayName = NULL; /* Var Name */ } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, $9 ) ; /* Picture */ } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, $12 ); /* ValidBlock */ } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, $15 ); /* WhenBlock */ } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, hb_compExprNewArray( pArrayIndexAsList ) ); /* Array with Index Expressions as 6th parameter */ } + GetAExt ')' { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GETA"), pGetArgList ); pGetArgList = NULL; } + | GET AliasVar ArrayIndex { pGetArgList = hb_compExprNewArgList( $2 ); bTrancuateBaseArray = TRUE; } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, ( pBaseArrayName ? pBaseArrayName : $6 ) ); pBaseArrayName = NULL; /* Var Name */ } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, $9 ) ; /* Picture */ } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, $12 ); /* ValidBlock */ } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, $15 ); /* WhenBlock */ } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, hb_compExprNewArray( pArrayIndexAsList ) ); /* Array with Index Expressions as 6th parameter */ } + GetAExt ')' { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GETA"), pGetArgList ); pGetArgList = NULL; } + | GET MacroVar ArrayIndex { pGetArgList = hb_compExprNewArgList( $2 ); bTrancuateBaseArray = TRUE; } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, ( pBaseArrayName ? pBaseArrayName : $6 ) ); pBaseArrayName = NULL; /* Var Name */ } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, $9 ) ; /* Picture */ } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, $12 ); /* ValidBlock */ } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, $15 ); /* WhenBlock */ } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, hb_compExprNewArray( pArrayIndexAsList ) ); /* Array with Index Expressions as 6th parameter */ } + GetAExt ')' { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GETA"), pGetArgList ); pGetArgList = NULL; } + | GET MacroExpr ArrayIndex { pGetArgList = hb_compExprNewArgList( $2 ); bTrancuateBaseArray = TRUE; } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, ( pBaseArrayName ? pBaseArrayName : $6 ) ); pBaseArrayName = NULL; /* Var Name */ } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, $9 ) ; /* Picture */ } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, $12 ); /* ValidBlock */ } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, $15 ); /* WhenBlock */ } ',' + EmptyExpression { hb_compExprAddListExpr( pGetArgList, hb_compExprNewArray( pArrayIndexAsList ) ); /* Array with Index Expressions as 6th parameter */ } + GetAExt ')' { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GETA"), pGetArgList ); pGetArgList = NULL; } + ; + +GetAExt : { /* Nothing*/ } + | ',' GetArgList + ; + /* NOTE: This uses $-2 then don't use BlockExpList in other context */ BlockExpList : Expression { $$ = hb_compExprAddListExpr( $-2, $1 ); } diff --git a/harbour/source/macro/macro.slx b/harbour/source/macro/macro.slx index b939cd2f0b..990478e41b 100644 --- a/harbour/source/macro/macro.slx +++ b/harbour/source/macro/macro.slx @@ -50,7 +50,7 @@ * NOTE: yylval_ptr is passed automaticaly by bison if %pure_parser is used */ #undef YY_DECL - #define YY_DECL int yylex( YYSTYPE *yylval_ptr ) + #define YY_DECL int yylex( YYSTYPE *yylval_ptr, HB_MACRO_PTR pMacro ) #define YYLEX_PARAM pMacro diff --git a/harbour/source/rtl/tget.prg b/harbour/source/rtl/tget.prg index 814ed35ad7..530aa204e9 100644 --- a/harbour/source/rtl/tget.prg +++ b/harbour/source/rtl/tget.prg @@ -1111,10 +1111,6 @@ return Get():New( nRow, nCol, bVarBlock, cVarName, cPicture, cColor ) //---------------------------------------------------------------------------// -/* Until support of __GET and __GETA() built into harbour.y */ -FUNCTION _GET_( uVar, cVarName, cPicture, bValid, bWhen, bSetGet ) -RETURN __GET( uVar, cVarName, cPicture, bValid, bWhen, bSetGet ) - FUNCTION __GET( uVar, cVarName, cPicture, bValid, bWhen, bSetGet ) LOCAL oGet := Get():New(,, bSetGet, cVarName, cPicture )