2006-11-08 12:55 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/bin/hb-func.sh
+ added linker parametrs to hbcc
* harbour/include/hbapi.h
+ added hb_retclenAdoptRaw()
* harbour/include/hbapifs.h
* harbour/source/common/hbfsapi.c
* changed first parameters of hb_fsAddSearchPath() to const char *
* harbour/include/hbclass.ch
* update for new PP. I think that now we can try to create final
version of our OOP rules.
* harbour/include/hbdefs.h
+ added UCHAR and SCHAR typedefs
* harbour/include/hbrddcdx.h
* indenting
* harbour/source/rdd/workarea.c
! fixed minor typo
* harbour/source/common/hbdate.c
* harbour/source/rtl/dates.c
* moved hb_dateToday() and hb_dateTimeStr() from RTL to COMMON library
- harbour/include/hbpp.h
- harbour/source/pp/ppcomp.c
- harbour/source/pp/ppcore.c
- harbour/source/pp/pplib.c
- harbour/source/pp/pptable.c
- harbour/source/pp/pragma.c
* harbour/utils/hbpp/Makefile
* harbour/utils/hbpp/hbpp.c
+ harbour/utils/hbpp/hbpp.h
+ harbour/utils/hbpp/ppcomp.c
+ harbour/utils/hbpp/ppcore.c
+ harbour/utils/hbpp/pplib.c
+ harbour/utils/hbpp/pptable.c
+ harbour/utils/hbpp/pragma.c
* moved all PP code to harbour/utils/hbpp
It's interesting and working preprocessor and the code can be
usable for some other things so I do not want to remove it.
Probablly we should move it to contrib/hbpptext
* harbour/include/hbcomp.h
* harbour/include/hberrors.h
* harbour/include/hbsetup.ch
+ harbour/include/hbpp.h
+ harbour/include/hbstdgen.ch
* harbour/source/common/hbstr.c
* harbour/source/compiler/Makefile
* harbour/source/compiler/cmdcheck.c
* harbour/source/compiler/harbour.c
* harbour/source/compiler/harbour.l
* harbour/source/compiler/hbgenerr.c
+ harbour/source/compiler/ppcomp.c
* harbour/source/pp/Makefile
+ harbour/source/pp/ppcore.c
+ harbour/source/pp/pplib.c
+ harbour/source/pp/ppgen.c
+ New PP code written from scratch. It works in similar way to
Clipper PP even the error codes are replicated. The code is MT
safe does not have any limitation on size of preprocessed code,
line, etc. It's also Clipper compatible lexer. It means that
we do not longer need FLEX or SIMPLEX which can be replaced
by new PP after some small modifications. Anyhow I haven't
decided to make it myself. I would like to agree with with the
rest of developers. I will be very happy if such modifications
will be done by someone else, Ryszard?
Meanwhile I current PP join on output the line tokens and give
the string line to FLEX/SIMPLEX. It does not have any sense and
all FLEX/SIMPLEX limitations are still existing. Ryszard, even
if we keep it then I hope you can remove at least FLEX line buffer
and use the one returned from PP.
Because string tokens in parsed line are converted to text which is
later once again decoded to tokens by FLEX I had to introduce new
string format which supports embedded string delimiters. I chose
modified version of xHarbour extension with escaped strings e"<sting>"
so now FLEX understand such strings and decode them like C escaped
strings. It means that you can use them also in the .prg code f.e.:
outstd( e"Hello\n\rWorld" )
The new PP is also noticeable faster. You should see the difference
compiling long files. The build in PP rules are generated automatically
by ppgen program created from source/pp/ppgen.c
I had to add to GNU source/pp/Makefile these two lines:
pptable.c : ppgen$(EXE_EXT)
./ppgen$(EXE_EXT) $(TOP)$(ROOT)include/hbstdgen.ch -opptable.c -q
Sth like that will have to be done also in non GNU make system.
Now Harbour can be compiled only using GNU make.
Marek can you update non GNU make files? I would like to leave this
modification to you or other developers who can test it.
It was quite big modification and I do not believe that I haven't
make any mistakes but I hope that in few weeks I'll fix any reported
bugs and it will resolve any PP problems.
TODO:
* error messages
create one common list of errors and warnings and keep it
in common library. PP and compiler can still generate different
errors with the same number. It can be confusing for the users
and hard to document and add i18n translations.
If possible we should also try to keep Clipper error numbers.
In new PP code I added Clipper error numbers but I cannot use
them until compiler code is not updated.
We should aslo remove the ctype passed to error functions and
hack with first character in warning messages and use only
error number. The codes from 1000 to 1999 should be warnings
where range 1000:1099 is activated by -w, 1100:1199 by -w1,
1200:1299 by -w2, etc. 2000:2999 are errors and 3000:3999
fatal errors. All compiler functions which generate an error
should expect that error function will not stop the compiler
but return and cleanly finished their job. It's necessary for
MT support in compiler and making compiler part of some other
programs which may still work and compile different source code.
* FLEX/SIMPLEX
remove them at all and add some final pass to PP to create
more precise tokens for grammar parser or at least add better
integration to remove some redundant code and existing limits.
* hb_inLine() support - it's broken in new PP but as I can see
it was never working correctly. I can add a hack to PP to support
hb_inLine() but I'm not sure it's worth to do. Maybe in few days.
+ harbour/include/std.ch
+ added new std.ch. It was created without using Clipper's std.ch.
It's quite possible that some rules are wrong and should be fixed
so please help. Anyhow I created a set of programs based on new PP
code generating all possible combinations of different commands I
collected from different source code, documentation and match patterns
of rules I was adding to new std.ch and then I was comparing .ppo
files generated by Clipper and Harbour so I do not expect any bigger
problems then some minor typos. I had to introduce some modifications
in spacing as workaround for FLEX/SIMPLEX which cannot properly decode
text preprocessed by Clipper after stringify.
* harbour/utils/hbpptest/pretest.prg
* updated for new PP
It reports 16 wrong translations but some of them are valid
and some others are caused by escaped string e"..." (one of hack
for FLEX/SIMPLEX support)
I also had to remove all spaces in comparison the results
because they were not Clipper ocmpatible at all. Ryszard please
look at it.
This commit is contained in:
@@ -8,6 +8,151 @@
|
||||
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
|
||||
to character not symbol item type.
|
||||
|
||||
2006-11-08 13:40 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/source/pp/ppcore.c
|
||||
* cleaned two warnings generated by old GCC versions
|
||||
|
||||
2006-11-08 12:55 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/bin/hb-func.sh
|
||||
+ added linker parametrs to hbcc
|
||||
|
||||
* harbour/include/hbapi.h
|
||||
+ added hb_retclenAdoptRaw()
|
||||
|
||||
* harbour/include/hbapifs.h
|
||||
* harbour/source/common/hbfsapi.c
|
||||
* changed first parameters of hb_fsAddSearchPath() to const char *
|
||||
|
||||
* harbour/include/hbclass.ch
|
||||
* update for new PP. I think that now we can try to create final
|
||||
version of our OOP rules.
|
||||
|
||||
* harbour/include/hbdefs.h
|
||||
+ added UCHAR and SCHAR typedefs
|
||||
|
||||
* harbour/include/hbrddcdx.h
|
||||
* indenting
|
||||
|
||||
* harbour/source/rdd/workarea.c
|
||||
! fixed minor typo
|
||||
|
||||
* harbour/source/common/hbdate.c
|
||||
* harbour/source/rtl/dates.c
|
||||
* moved hb_dateToday() and hb_dateTimeStr() from RTL to COMMON library
|
||||
|
||||
- harbour/include/hbpp.h
|
||||
- harbour/source/pp/ppcomp.c
|
||||
- harbour/source/pp/ppcore.c
|
||||
- harbour/source/pp/pplib.c
|
||||
- harbour/source/pp/pptable.c
|
||||
- harbour/source/pp/pragma.c
|
||||
* harbour/utils/hbpp/Makefile
|
||||
* harbour/utils/hbpp/hbpp.c
|
||||
+ harbour/utils/hbpp/hbpp.h
|
||||
+ harbour/utils/hbpp/ppcomp.c
|
||||
+ harbour/utils/hbpp/ppcore.c
|
||||
+ harbour/utils/hbpp/pplib.c
|
||||
+ harbour/utils/hbpp/pptable.c
|
||||
+ harbour/utils/hbpp/pragma.c
|
||||
* moved all PP code to harbour/utils/hbpp
|
||||
It's interesting and working preprocessor and the code can be
|
||||
usable for some other things so I do not want to remove it.
|
||||
Probablly we should move it to contrib/hbpptext
|
||||
|
||||
* harbour/include/hbcomp.h
|
||||
* harbour/include/hberrors.h
|
||||
* harbour/include/hbsetup.ch
|
||||
+ harbour/include/hbpp.h
|
||||
+ harbour/include/hbstdgen.ch
|
||||
* harbour/source/common/hbstr.c
|
||||
* harbour/source/compiler/Makefile
|
||||
* harbour/source/compiler/cmdcheck.c
|
||||
* harbour/source/compiler/harbour.c
|
||||
* harbour/source/compiler/harbour.l
|
||||
* harbour/source/compiler/hbgenerr.c
|
||||
+ harbour/source/compiler/ppcomp.c
|
||||
* harbour/source/pp/Makefile
|
||||
+ harbour/source/pp/ppcore.c
|
||||
+ harbour/source/pp/pplib.c
|
||||
+ harbour/source/pp/ppgen.c
|
||||
+ New PP code written from scratch. It works in similar way to
|
||||
Clipper PP even the error codes are replicated. The code is MT
|
||||
safe does not have any limitation on size of preprocessed code,
|
||||
line, etc. It's also Clipper compatible lexer. It means that
|
||||
we do not longer need FLEX or SIMPLEX which can be replaced
|
||||
by new PP after some small modifications. Anyhow I haven't
|
||||
decided to make it myself. I would like to agree with with the
|
||||
rest of developers. I will be very happy if such modifications
|
||||
will be done by someone else, Ryszard?
|
||||
Meanwhile I h may no flush data in PreExt()
|
||||
|
||||
* harbour/source/rtl/gtwin/gtwin.c
|
||||
! fixed Init() code by adding missing SUPER_INIT()
|
||||
* modified a little bit PreExt() and PostExt() methods
|
||||
|
||||
2006-02-08 20:23 UTC+0100 Antonio Linares <alinares@fivetechsoft.com>
|
||||
* makefile.nt
|
||||
* makefile64.nt
|
||||
* updated with recent changes
|
||||
|
||||
./ppgen$(EXE_EXT) $(TOP)$(ROOT)include/hbstdgen.ch -opptable.c -q
|
||||
* harbour/source/rtl/gtwin/gtwin.c
|
||||
+ added PreExt() and PostExt() methods
|
||||
|
||||
2006-02-08 15:17 UTC+0100 PrzemyslawI chose
|
||||
modified version of xHarbour extension with escaped strings e"<sting>"
|
||||
so now FLEX understand such strings and decode them like C escaped
|
||||
strings. It means that you can use them also in the .prg code f.e.:
|
||||
outstd( e"Hello\n\rWorld" )
|
||||
The new PP is also noticeable faster. You should see the difference
|
||||
compiling long files. The build in PP rules are generated automatically
|
||||
by ppgen program created from source/pp/ppgen.c
|
||||
I had to add to GNU source/pp/Makefile these two lines:
|
||||
pptable.c : ppgen$(EXE_EXT)
|
||||
./ppgen$(EXE_EXT) $(TOP)$(ROOT)include/hbstdgen.ch -opptable.c -q
|
||||
Sth like that will have to be done also in non GNU make system.
|
||||
Now Harbour can be compiled only using GNU make.
|
||||
Marek can you update non GNU make files? I would like to leave this
|
||||
modification to you or other developers who can test it.
|
||||
It was quite big modification and I do not believe that I haven't
|
||||
make any mistakes but I hope that in few weeks I'll fix any reported
|
||||
bugs and it will resolve any PP problems.
|
||||
TODO:
|
||||
* error messages
|
||||
create one common list of errors and warnings and keep it
|
||||
in common library. PP and compiler can still generate different
|
||||
errors with the same number. It can be confusing for the users
|
||||
and hard to document and add i18n translations.
|
||||
If possible we should also try to keep Clipper error numbers.
|
||||
In new PP code I added Clipper error numbers but I cannot use
|
||||
them until compiler code is not updated.
|
||||
We should aslo remove the ctype passed to error functions and
|
||||
hack with first character in warning messages and use only
|
||||
error number. The codes from 1000 to 1999 should be warnings
|
||||
where range 1000:1099 is activated by -w, 1100:1199 by -w1,
|
||||
1200:1299 by -w2, etc. 2000:2999 are errors and 3000:3999
|
||||
fatal errors. All compiler functions which generate an error
|
||||
should expect that error function will not stop the compiler
|
||||
but return and cleanly finished their job. It's necessary for
|
||||
MT support in compiler and making compiler part of some other
|
||||
programs which may still work and compile different source code.
|
||||
* FLEX/SIMPLEX
|
||||
remove them at all and add some final pass to PP to create
|
||||
more precise tokens for grammar parser or at least add better
|
||||
integration to remove some redundant code and existing limits.
|
||||
* hb_inLine() support - it's broken in new PP but as I can see
|
||||
it was never working correctly. I can add a hack to PP to support
|
||||
hb_inLine() but I'm not sure it's worth to do. Maybe in few days.
|
||||
|
||||
+ harbour/include/std.ch
|
||||
+ added new std.ch. It was created without using Clipper's std.ch.
|
||||
It's quite possible that some rules are wrong and should be fixed
|
||||
so please help. Anyhow I created a set of programs based on new PP
|
||||
code generating all possible combinations of different commands I
|
||||
collected from different source code, documentation and match patterns
|
||||
of rules I was adding to new std.ch and then I was comparing .ppo
|
||||
files generated by Clipper and Harbour so I do not expect any bigger
|
||||
problems then some minor typos. I had to introduce some modifications
|
||||
in spacing as workaround for FLEX/SIMPLEX which cannot properly decode
|
||||
|
||||
@@ -409,7 +409,7 @@ FOUTE="\${FOUTE%.[oc]}${hb_exesuf}"
|
||||
|
||||
hb_cc()
|
||||
{
|
||||
${CCPREFIX}\${HB_CC} "\$@" \${CC_OPT} \${GCC_PATHS}
|
||||
${CCPREFIX}\${HB_CC} "\$@" \${CC_OPT} \${GCC_PATHS} \${HB_USRLPATH} \${HB_USRLIBS}
|
||||
}
|
||||
|
||||
hb_cmp()
|
||||
|
||||
@@ -448,6 +448,7 @@ extern HB_EXPORT void hb_retnlllen( LONGLONG lNumber, int iWidth ); /* returns
|
||||
/* xHarbour compatible function */
|
||||
#define hb_retcAdopt( szText ) hb_retc_buffer( (szText) )
|
||||
#define hb_retclenAdopt( szText, ulLen ) hb_retclen_buffer( (szText), (ulLen) )
|
||||
#define hb_retclenAdoptRaw( szText, ulLen ) hb_retclen_buffer( (szText), (ulLen) )
|
||||
#define hb_retcStatic( szText ) hb_retc_const( (szText) )
|
||||
|
||||
#ifdef HB_API_MACROS
|
||||
|
||||
@@ -178,7 +178,7 @@ typedef struct _HB_PATHNAMES
|
||||
BOOL fFree;
|
||||
} HB_PATHNAMES;
|
||||
|
||||
extern HB_EXPORT void hb_fsAddSearchPath( char * szPath, HB_PATHNAMES ** pSearchList );
|
||||
extern HB_EXPORT void hb_fsAddSearchPath( const char * szPath, HB_PATHNAMES ** pSearchList );
|
||||
extern HB_EXPORT void hb_fsFreeSearchPath( HB_PATHNAMES * pSearchList );
|
||||
|
||||
extern HB_EXPORT BOOL hb_spFile( BYTE * pFilename, BYTE * pRetPath );
|
||||
|
||||
@@ -181,7 +181,7 @@
|
||||
#ifdef HB_CLS_NO_OO_ERR
|
||||
#xtranslate __HB_CLS_ERR([<msg,...>]) =>
|
||||
#else
|
||||
#xtranslate __HB_CLS_ERR([<msg,...>]) => ;#error [<msg>] ; #undef _DUMMY_DEF_
|
||||
#xtranslate __HB_CLS_ERR([<msg,...>]) => ;#error [ <msg>] ; #undef _DUMMY_DEF_
|
||||
#endif
|
||||
|
||||
#xtranslate __HB_CLS_VARERR(<var>) => __HB_CLS_ERR( Invalid instance variable name: <var> )
|
||||
@@ -221,8 +221,8 @@ DECLARE HBClass ;
|
||||
#xtranslate __HB_CLS_ASARGS( <FuncName>([<Args,...>]) ) => [<Args>]
|
||||
#xtranslate __HB_CLS_ASARGSOPT( <FuncName> ) =>
|
||||
#xtranslate __HB_CLS_ASARGSOPT( <FuncName>([<Args,...>]) ) => [, <Args>]
|
||||
#xtranslate __HB_CLS_ISVAR( <var> ) =>
|
||||
#xtranslate __HB_CLS_ISVAR( <var>([<params,...>]) ) => __HB_CLS_VARERR(<var>([<params>]))
|
||||
#xtranslate __HB_CLS_ISVAR( <var> ) => __HB_CLS_VARERR(<var>)
|
||||
#xtranslate __HB_CLS_ISVAR( <!var!> ) =>
|
||||
#xcommand __HB_CLS_CHECKVAR( <param1> [,<paramN>] ) => __HB_CLS_ISVAR( <param1> ) [;__HB_CLS_ISVAR( <paramN> )]
|
||||
|
||||
/* #xtranslate __HB_CLS_SCOPE( <export>, <protect>, <hidde> ) => ;
|
||||
@@ -257,7 +257,7 @@ DECLARE HBClass ;
|
||||
|
||||
#xcommand ENDCLASS => ;
|
||||
s_oClass:Create() ;;
|
||||
endif ;;
|
||||
end ;;
|
||||
return s_oClass:Instance() AS CLASS _CLASS_NAME_ ;;
|
||||
#undef _CLASS_MODE_ ; #define _CLASS_MODE_ _CLASS_IMPLEMENTATION_
|
||||
|
||||
@@ -273,7 +273,7 @@ DECLARE HBClass ;
|
||||
#undef _DUMMY_DEF_
|
||||
#else
|
||||
#xcommand __HB_CLS_DECLARE_METHOD <MethodName> <ClassName> => ;
|
||||
#xcommand METHOD \<type: FUNCTION, PROCEDURE> <MethodName>\[(\[<xparams,...>])] CLASS <ClassName> _CLASS_IMPLEMENTATION_ => ;
|
||||
#xcommand METHOD \<type: FUNCTION, PROCEDURE> <MethodName>\[(\[\<xparams,...>])] CLASS <ClassName> _CLASS_IMPLEMENTATION_ => ;
|
||||
DECLARED METHOD \<type> <MethodName>\[(\<xparams>)] CLASS <ClassName>
|
||||
#endif
|
||||
|
||||
@@ -286,7 +286,7 @@ DECLARE HBClass ;
|
||||
__HB_CLS_DECLARE_METHOD __HB_CLS_PARAMS(<MethodName>) _CLASS_NAME_ ;;
|
||||
s_oClass:AddMethod( __HB_CLS_ASSTRING(<MethodName>), @__HB_CLS_ASID( __HB_CLS_MTHNAME _CLASS_NAME_ <MethodName> )(), __HB_CLS_SCOPE( <.export.>, <.protect.>, <.hidde.> ) + iif( <.ctor.>, HB_OO_CLSTP_CTOR, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ) )
|
||||
|
||||
#xcommand ACCESS <AccessName>[()] [ AS <type> ] [ <export: EXPORTED, VISIBLE>] [<protect: PROTECTED>] [<hidde: HIDDEN>] [<persistent: PERSISTENT, PROPERTY>] [_CLASS_DECLARATION_] => ;
|
||||
#xcommand ACCESS <AccessName> [ AS <type> ] [ <export: EXPORTED, VISIBLE>] [<protect: PROTECTED>] [<hidde: HIDDEN>] [<persistent: PERSISTENT, PROPERTY>] [_CLASS_DECLARATION_] => ;
|
||||
METHOD <AccessName> [ AS <type> ] <export> <protect> <hidde> <persistent> _CLASS_DECLARATION_
|
||||
|
||||
#xcommand ASSIGN <AssignName> [ AS <type> ] [ <export: EXPORTED, VISIBLE>] [<protect: PROTECTED>] [<hidde: HIDDEN>] [<persistent: PERSISTENT, PROPERTY>] [_CLASS_DECLARATION_] => ;
|
||||
@@ -385,7 +385,7 @@ DECLARE HBClass ;
|
||||
MESSAGE <MessageName> [ AS <type> ] TO <oObject> <export> <protect> <hidde> <persistent>
|
||||
|
||||
#xcommand ACCESS <MessageName> [ AS <type> ] [LOCAL <Locals,...>] INLINE <Code,...> [<export: EXPORTED, VISIBLE>] [<protect: PROTECTED>] [<hidde: HIDDEN>] [<persistent: PERSISTENT, PROPERTY>] => ;
|
||||
MESSAGE __HB_CLS_ASID(<MessageName>) [ AS <type> ] [LOCAL <Locals>] INLINE <Code> <export> <protect> <hidde> <persistent>
|
||||
MESSAGE <MessageName> [ AS <type> ] [LOCAL <Locals>] INLINE <Code> <export> <protect> <hidde> <persistent>
|
||||
|
||||
#xcommand ASSIGN <MessageName> [ AS <type> ] [LOCAL <Locals,...>] INLINE <Code,...> [<export: EXPORTED, VISIBLE>] [<protect: PROTECTED>] [<hidde: HIDDEN>] [<persistent: PERSISTENT, PROPERTY>] => ;
|
||||
MESSAGE _<MessageName> [ AS <type> ] [LOCAL <Locals>] INLINE <Code> <export> <protect> <hidde> <persistent>
|
||||
@@ -437,11 +437,11 @@ DECLARE HBClass ;
|
||||
|
||||
/* The #xtranslate is wrongly used instead of #xcommand as
|
||||
workaround for some preprocessor problems */
|
||||
#xtranslate EXPORTED: => nScope := HB_OO_CLSTP_EXPORTED
|
||||
#xtranslate EXPORT: => nScope := HB_OO_CLSTP_EXPORTED
|
||||
#xtranslate VISIBLE: => nScope := HB_OO_CLSTP_EXPORTED
|
||||
#xtranslate HIDDEN: => nScope := HB_OO_CLSTP_HIDDEN
|
||||
#xtranslate PROTECTED: => nScope := HB_OO_CLSTP_PROTECTED
|
||||
#xcommand EXPORTED: => nScope := HB_OO_CLSTP_EXPORTED
|
||||
#xcommand EXPORT: => nScope := HB_OO_CLSTP_EXPORTED
|
||||
#xcommand VISIBLE: => nScope := HB_OO_CLSTP_EXPORTED
|
||||
#xcommand HIDDEN: => nScope := HB_OO_CLSTP_HIDDEN
|
||||
#xcommand PROTECTED: => nScope := HB_OO_CLSTP_PROTECTED
|
||||
|
||||
|
||||
// Classy compatibility... Added By JF Lefebvre (mafact) 2006/11/07
|
||||
@@ -456,30 +456,30 @@ DECLARE HBClass ;
|
||||
|
||||
#xcommand VAR <DataNames,...> [ <tp: TYPE, AS> <type> ] [ <as: ASSIGN, INIT> <uValue> ] [<export: EXPORTED, VISIBLE>] [<protect: PROTECTED>] [<hidde: HIDDEN>] [<ro: READONLY, RO>] [<persistent: PERSISTENT, PROPERTY>] => ;
|
||||
__HB_CLS_CHECKVAR(<DataNames>);;
|
||||
_HB_MEMBER {[AS <type>] <DataNames>} ;;
|
||||
_HB_MEMBER {[ AS <type>] <DataNames> } ;;
|
||||
s_oClass:AddMultiData( <(type)>, <uValue>, __HB_CLS_SCOPE( <.export.>, <.protect.>, <.hidde.> ) + iif( <.ro.>, HB_OO_CLSTP_READONLY, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ), {<(DataNames)>}, __HB_CLS_NOINI )
|
||||
|
||||
#xcommand VAR <DataName> [ AS <type> ] IN <SuperClass> => ;
|
||||
__HB_CLS_CHECKVAR(<DataName>);;
|
||||
_HB_MEMBER {[AS <type>] <DataName>} ;;
|
||||
_HB_MEMBER {[ AS <type>] <DataName> } ;;
|
||||
s_oClass:AddInline( <(DataName)>, {|Self| Self:<SuperClass>:<DataName> }, HB_OO_CLSTP_EXPORTED + HB_OO_CLSTP_READONLY ) ;;
|
||||
s_oClass:AddInline( "_" + <(DataName)>, {|Self, param| Self:<SuperClass>:<DataName> := param }, HB_OO_CLSTP_EXPORTED )
|
||||
|
||||
#xcommand VAR <DataName> [ AS <type> ] IS <SprDataName> IN <SuperClass> => ;
|
||||
__HB_CLS_CHECKVAR(<DataName>);;
|
||||
_HB_MEMBER {[AS <type>] <DataName>} ;;
|
||||
_HB_MEMBER {[ AS <type>] <DataName> } ;;
|
||||
s_oClass:AddInline( <(DataName)>, {|Self| Self:<SuperClass>:<SprDataName> }, HB_OO_CLSTP_EXPORTED + HB_OO_CLSTP_READONLY ) ;;
|
||||
s_oClass:AddInline( "_" + <(DataName)>, {|Self, param| Self:<SuperClass>:<SprDataName> := param }, HB_OO_CLSTP_EXPORTED )
|
||||
|
||||
#xcommand VAR <DataName1> [ AS <type> ] IS <DataName2> => ;
|
||||
__HB_CLS_CHECKVAR(<DataName1>);;
|
||||
_HB_MEMBER {[AS <type>] <DataName1>} ;;
|
||||
_HB_MEMBER {[ AS <type>] <DataName1> } ;;
|
||||
s_oClass:AddInline( <(DataName1)>, {|Self| Self:<DataName2> }, HB_OO_CLSTP_EXPORTED + HB_OO_CLSTP_READONLY ) ;;
|
||||
s_oClass:AddInline( "_" + <(DataName1)>, {|Self, param| Self:<DataName2> := param }, HB_OO_CLSTP_EXPORTED )
|
||||
|
||||
#xcommand VAR <DataName1> [ AS <type> ] IS <DataName2> TO <oObject> => ;
|
||||
__HB_CLS_CHECKVAR(<DataName1>);;
|
||||
_HB_MEMBER {[AS <type>] <DataName1>} ;;
|
||||
_HB_MEMBER {[ AS <type>] <DataName1> } ;;
|
||||
s_oClass:AddInline( <(DataName1)>, {|Self| Self:<oObject>:<DataName2> }, HB_OO_CLSTP_EXPORTED + HB_OO_CLSTP_READONLY ) ;;
|
||||
s_oClass:AddInline( "_" + <(DataName1)>, {|Self, param| Self:<oObject>:<DataName2> := param }, HB_OO_CLSTP_EXPORTED )
|
||||
|
||||
@@ -490,13 +490,13 @@ DECLARE HBClass ;
|
||||
|
||||
#xcommand DATA <DataNames,...> [ AS <type> ] [ INIT <uValue> ] [ <export: EXPORTED, VISIBLE>] [<protect: PROTECTED>] [<hidde: HIDDEN>] [<ro: READONLY, RO>] [<persistent: PERSISTENT, PROPERTY>] => ;
|
||||
__HB_CLS_CHECKVAR(<DataNames>);;
|
||||
_HB_MEMBER {[AS <type>] <DataNames>} ;;
|
||||
_HB_MEMBER {[ AS <type>] <DataNames> } ;;
|
||||
s_oClass:AddMultiData( <(type)>, <uValue>, __HB_CLS_SCOPE( <.export.>, <.protect.>, <.hidde.> ) + iif( <.ro.>, HB_OO_CLSTP_READONLY, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ), {<(DataNames)>}, __HB_CLS_NOINI )
|
||||
|
||||
/* Warning! For backward compatibility this CLASSDATA ignores the
|
||||
SHARED clause and always create shared class variables */
|
||||
#xcommand CLASSDATA <DataNames,...> [ AS <type> ] [ INIT <uValue> ] [<export: EXPORTED, VISIBLE>] [<protect: PROTECTED>] [<hidde: HIDDEN>] [<ro: READONLY, RO>] [<share: SHARED>] [<persistent: PERSISTENT, PROPERTY>] => ;
|
||||
_HB_MEMBER {[AS <type>] <DataNames>} ;;
|
||||
_HB_MEMBER {[ AS <type>] <DataNames> } ;;
|
||||
s_oClass:AddMultiClsData( <(type)>, <uValue>, __HB_CLS_SCOPE( <.export.>, <.protect.>, <.hidde.> ) + iif( <.ro.>, HB_OO_CLSTP_READONLY, 0 ) + iif( /* <.share.> */ .T., HB_OO_CLSTP_SHARED, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ), {<(DataNames)>}, __HB_CLS_NOINI )
|
||||
|
||||
#endif /* HB_CLS_FWO */
|
||||
@@ -508,20 +508,17 @@ DECLARE HBClass ;
|
||||
#xtranslate = <!name!>{ [<p,...>] } => = <name>():New( <p> )
|
||||
#xtranslate , <!name!>{ [<p,...>] } => , <name>():New( <p> )
|
||||
|
||||
#xcommand EXPORT <DataNames,...> [ <tp: TYPE, AS> <type> ] [ <as: ASSIGN, INIT> <uValue> ] [<ro: READONLY, RO>] [<persistent: PERSISTENT, PROPERTY>] => ;
|
||||
__HB_CLS_CHECKVAR(<DataNames>);;
|
||||
_HB_MEMBER {[AS <type>] <DataNames>} ;;
|
||||
s_oClass:AddMultiData( <(type)>, <uValue>, HB_OO_CLSTP_EXPORTED + iif( <.ro.>, HB_OO_CLSTP_READONLY, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ), {<(DataNames)>}, __HB_CLS_NOINI )
|
||||
#xcommand EXPORT <!DataName1!> [, <!DataNameN!>] [ <tp: TYPE, AS> <type> ] [ <as: ASSIGN, INIT> <uValue> ] [<ro: READONLY, RO>] [<persistent: PERSISTENT, PROPERTY>] => ;
|
||||
_HB_MEMBER {[ AS <type>] <DataName1> [, <DataNameN>] } ;;
|
||||
s_oClass:AddMultiData( <(type)>, <uValue>, HB_OO_CLSTP_EXPORTED + iif( <.ro.>, HB_OO_CLSTP_READONLY, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ), {<(DataName1)> [, <(DataNameN)>]}, __HB_CLS_NOINI )
|
||||
|
||||
#xcommand PROTECT <DataNames,...> [ <tp: TYPE, AS> <type> ] [ <as: ASSIGN, INIT> <uValue> ] [<ro: READONLY, RO>] [<persistent: PERSISTENT, PROPERTY>] => ;
|
||||
__HB_CLS_CHECKVAR(<DataNames>);;
|
||||
_HB_MEMBER {[AS <type>] <DataNames>} ;;
|
||||
s_oClass:AddMultiData( <(type)>, <uValue>, HB_OO_CLSTP_PROTECTED + iif( <.ro.>, HB_OO_CLSTP_READONLY, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ), {<(DataNames)>}, __HB_CLS_NOINI )
|
||||
#xcommand PROTECT <!DataName1!> [, <!DataNameN!>] [ <tp: TYPE, AS> <type> ] [ <as: ASSIGN, INIT> <uValue> ] [<ro: READONLY, RO>] [<persistent: PERSISTENT, PROPERTY>] => ;
|
||||
_HB_MEMBER {[ AS <type>] <DataName1> [, <DataNameN>] } ;;
|
||||
s_oClass:AddMultiData( <(type)>, <uValue>, HB_OO_CLSTP_PROTECTED + iif( <.ro.>, HB_OO_CLSTP_READONLY, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ), {<(DataName1)> [, <(DataNameN)>]}, __HB_CLS_NOINI )
|
||||
|
||||
#xcommand HIDDE <DataNames,...> [ <tp: TYPE, AS> <type> ] [ <as: ASSIGN, INIT> <uValue> ] [<ro: READONLY, RO>] [<persistent: PERSISTENT, PROPERTY>] => ;
|
||||
__HB_CLS_CHECKVAR(<DataNames>);;
|
||||
_HB_MEMBER {[AS <type>] <DataNames>} ;;
|
||||
s_oClass:AddMultiData( <(type)>, <uValue>, HB_OO_CLSTP_HIDDEN + iif( <.ro.>, HB_OO_CLSTP_READONLY, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ), {<(DataNames)>}, __HB_CLS_NOINI )
|
||||
#xcommand HIDDE <!DataName1!> [, <!DataNameN!>] [ <tp: TYPE, AS> <type> ] [ <as: ASSIGN, INIT> <uValue> ] [<ro: READONLY, RO>] [<persistent: PERSISTENT, PROPERTY>] => ;
|
||||
_HB_MEMBER {[ AS <type>] <DataName1> [, <DataNameN>] } ;;
|
||||
s_oClass:AddMultiData( <(type)>, <uValue>, HB_OO_CLSTP_HIDDEN + iif( <.ro.>, HB_OO_CLSTP_READONLY, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ), {<(DataName1)> [, <(DataNameN)>]}, __HB_CLS_NOINI )
|
||||
|
||||
#endif /* HB_CLS_VO */
|
||||
|
||||
@@ -533,9 +530,8 @@ DECLARE HBClass ;
|
||||
__HB_CLS_DECLARE_METHOD __HB_CLS_PARAMS(<MethodName>) _CLASS_NAME_ ;;
|
||||
s_oClass:AddClsMthds( __HB_CLS_ASSTRING(<MethodName>), @__HB_CLS_ASID( __HB_CLS_MTHNAME _CLASS_NAME_ <MethodName> )(), __HB_CLS_SCOPE( <.export.>, <.protect.>, <.hidde.> ) + iif( <.share.>, HB_OO_CLSTP_SHARED, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ) )
|
||||
|
||||
#xcommand CLASSVAR <DataNames,...> [ <tp: TYPE, AS> <type> ] [ <as: ASSIGN, INIT> <uValue> ] [<export: EXPORTED, VISIBLE>] [<protect: PROTECTED>] [<hidde: HIDDEN>] [<ro: READONLY, RO>] [<share: SHARED>] [<persistent: PERSISTENT, PROPERTY>] => ;
|
||||
__HB_CLS_CHECKVAR(<DataNames>);;
|
||||
_HB_MEMBER {[AS <type>] <DataNames>} ;;
|
||||
s_oClass:AddMultiClsData( <(type)>, <uValue>, __HB_CLS_SCOPE( <.export.>, <.protect.>, <.hidde.> ) + iif( <.ro.>, HB_OO_CLSTP_READONLY, 0 ) + iif( <.share.>, HB_OO_CLSTP_SHARED, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ), {<(DataNames)>}, __HB_CLS_NOINI )
|
||||
#xcommand CLASSVAR <!DataName1!> [, <!DataNameN!>] [ <tp: TYPE, AS> <type> ] [ <as: ASSIGN, INIT> <uValue> ] [<export: EXPORTED, VISIBLE>] [<protect: PROTECTED>] [<hidde: HIDDEN>] [<ro: READONLY, RO>] [<share: SHARED>] [<persistent: PERSISTENT, PROPERTY>] => ;
|
||||
_HB_MEMBER {[ AS <type>] <DataName1> [, <DataNameN>] } ;;
|
||||
s_oClass:AddMultiClsData( <(type)>, <uValue>, __HB_CLS_SCOPE( <.export.>, <.protect.>, <.hidde.> ) + iif( <.ro.>, HB_OO_CLSTP_READONLY, 0 ) + iif( <.share.>, HB_OO_CLSTP_SHARED, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ), {<(DataName1)> [, <(DataNameN)>]}, __HB_CLS_NOINI )
|
||||
|
||||
#endif /* HB_CLASS_CH_ */
|
||||
|
||||
@@ -470,8 +470,6 @@ extern void hb_compFileInfo( void );
|
||||
extern void hb_compPrintLogo( void );
|
||||
extern void hb_compPrintModes( void );
|
||||
|
||||
extern int hb_compCompile( char * szPrg, int argc, char * argv[], BOOL bSingleFile );
|
||||
|
||||
#endif /* HB_MACRO_SUPPORT */
|
||||
|
||||
/* Misc functions defined in harbour.c */
|
||||
@@ -597,6 +595,25 @@ extern const BYTE hb_comp_pcode_len[];
|
||||
/* error messages output */
|
||||
extern FILE *hb_comp_errFile;
|
||||
|
||||
/* Hide Strings */
|
||||
extern int hb_comp_iHidden;
|
||||
|
||||
/* compiler PP functions and variables */
|
||||
#define HB_PP_STR_SIZE 12288
|
||||
#define HB_PP_BUFF_SIZE 4096
|
||||
extern void hb_pp_SetRules( BOOL hb_comp_bQuiet, int argc, char * argv[] );
|
||||
extern void hb_pp_Init( void );
|
||||
extern void hb_pp_Free( void );
|
||||
extern void hb_pp_AddDefine( char *defname, char *value );
|
||||
extern void hb_pp_ParseDirective( char * );
|
||||
extern int hb_pp_Internal( FILE *, char * );
|
||||
|
||||
extern BOOL hb_pp_LiteralEscSeq;
|
||||
extern BOOL hb_pp_NestedLiteralString;
|
||||
extern int hb_pp_StreamBlock;
|
||||
extern unsigned int hb_pp_MaxTranslateCycles;
|
||||
|
||||
|
||||
/* /GC command line setting types */
|
||||
#define HB_COMPGENC_COMPACT 0
|
||||
#define HB_COMPGENC_NORMAL 1
|
||||
|
||||
@@ -165,6 +165,12 @@
|
||||
#undef UINT /* varies with platform */
|
||||
typedef unsigned int UINT;
|
||||
|
||||
#undef SCHAR /* 1 byte signed */
|
||||
typedef signed char SCHAR;
|
||||
|
||||
#undef UCHAR /* 1 byte unsigned */
|
||||
typedef unsigned char UCHAR;
|
||||
|
||||
#undef BYTE /* 1 byte unsigned */
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
|
||||
@@ -120,6 +120,7 @@ HB_EXTERN_BEGIN
|
||||
#define HB_COMP_ERR_MEMOVERFLOW 58
|
||||
#define HB_COMP_ERR_MEMCORRUPT 59
|
||||
#define HB_COMP_ERR_WITHOBJECT 60
|
||||
#define HB_COMP_ERR_BUFFER_OVERFLOW 61
|
||||
|
||||
#define HB_COMP_WARN_AMBIGUOUS_VAR 1
|
||||
#define HB_COMP_WARN_MEMVAR_ASSUMED 2
|
||||
@@ -153,34 +154,6 @@ HB_EXTERN_BEGIN
|
||||
#define HB_COMP_WARN_FORVAR_DUPL 30
|
||||
#define HB_COMP_WARN_ENUM_INVALID 31
|
||||
|
||||
/*
|
||||
* Errors generated by Harbour preprocessor
|
||||
*/
|
||||
#define HB_PP_ERR_CANNOT_OPEN 1
|
||||
#define HB_PP_ERR_DIRECTIVE_ELSE 2
|
||||
#define HB_PP_ERR_DIRECTIVE_ENDIF 3
|
||||
#define HB_PP_ERR_WRONG_NAME 4
|
||||
#define HB_PP_ERR_DEFINE_ABSENT 5
|
||||
#define HB_PP_ERR_COMMAND_DEFINITION 6
|
||||
#define HB_PP_ERR_PATTERN_DEFINITION 7
|
||||
#define HB_PP_ERR_RECURSE 8
|
||||
#define HB_PP_ERR_WRONG_DIRECTIVE 9
|
||||
#define HB_PP_ERR_EXPLICIT 10
|
||||
#define HB_PP_ERR_MEMALLOC 11
|
||||
#define HB_PP_ERR_MEMREALLOC 12
|
||||
#define HB_PP_ERR_MEMFREE 13
|
||||
#define HB_PP_ERR_PRAGMA_BAD_VALUE 14
|
||||
#define HB_PP_ERR_CANNOT_OPEN_RULES 15
|
||||
#define HB_PP_ERR_BAD_RULES_FILE_NAME 16
|
||||
#define HB_PP_ERR_TOO_MANY_INCLUDES 17
|
||||
#define HB_PP_ERR_BUFFER_OVERFLOW 18
|
||||
#define HB_PP_ERR_LABEL_MISSING_IN_DEFINE 19
|
||||
#define HB_PP_ERR_PARE_MISSING_IN_DEFINE 20
|
||||
#define HB_PP_ERR_LABEL_DUPL_IN_DEFINE 21
|
||||
|
||||
#define HB_PP_WARN_DEFINE_REDEF 1
|
||||
#define HB_PP_WARN_NO_DIRECTIVES 2
|
||||
|
||||
extern void hb_compGenError( char * szErrors[], char cPrefix, int iError, const char * szError1, const char * szError2 ); /* generic parsing error management function */
|
||||
extern void hb_compGenWarning( char * szWarnings[], char cPrefix, int iWarning, const char * szWarning1, const char * szWarning2); /* generic parsing warning management function */
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Header file for the Preprocesor
|
||||
*
|
||||
*
|
||||
* Copyright 1999 Alexander S.Kresin <alex@belacy.belgorod.su>
|
||||
* Copyright 2006 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -55,95 +55,553 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapifs.h"
|
||||
#include "hberrors.h"
|
||||
#include "hbver.h"
|
||||
|
||||
HB_EXTERN_BEGIN
|
||||
|
||||
struct _DEFINES;
|
||||
typedef struct _DEFINES
|
||||
{
|
||||
char * name;
|
||||
int namelen;
|
||||
char * pars;
|
||||
int npars;
|
||||
char * value;
|
||||
struct _DEFINES * last;
|
||||
} DEFINES;
|
||||
|
||||
struct _COMMANDS;
|
||||
typedef struct _COMMANDS
|
||||
{
|
||||
int com_or_xcom;
|
||||
char * name;
|
||||
int namelen;
|
||||
char * mpatt;
|
||||
char * value;
|
||||
struct _COMMANDS * last;
|
||||
} COMMANDS;
|
||||
|
||||
#define HB_PP_STR_SIZE 12288
|
||||
#define HB_PP_BUFF_SIZE 4096
|
||||
|
||||
#define HB_SKIPTABSPACES( sptr ) while( *( sptr ) == ' ' || *( sptr ) == '\t' ) ( sptr )++
|
||||
|
||||
/* PPCORE.C exported functions and variables */
|
||||
|
||||
#define HB_INCLUDE_FUNC_( hbFunc ) BOOL hbFunc( char *, HB_PATHNAMES * )
|
||||
typedef HB_INCLUDE_FUNC_( HB_INCLUDE_FUNC );
|
||||
typedef HB_INCLUDE_FUNC * HB_INCLUDE_FUNC_PTR;
|
||||
|
||||
extern void hb_pp_SetRules( HB_INCLUDE_FUNC_PTR hb_compInclude, BOOL hb_comp_bQuiet );
|
||||
extern int hb_pp_ReadRules( void );
|
||||
extern void hb_pp_Init( void );
|
||||
extern void hb_pp_Free( void );
|
||||
extern void hb_pp_CloseInclude( void );
|
||||
extern int hb_pp_ParseDirective( char * ); /* Parsing preprocessor directives ( #... ) */
|
||||
extern int hb_pp_ParseExpression( char *, char *, BOOL ); /* Parsing a line ( without preprocessor directive ) */
|
||||
extern int hb_pp_WrStr( FILE *, char * );
|
||||
extern int hb_pp_RdStr( FILE *, char *, int, BOOL, char *, int *, int * );
|
||||
extern void hb_pp_Stuff( char *, char *, int, int, int );
|
||||
extern int hb_pp_strocpy( char *, char * );
|
||||
extern DEFINES * hb_pp_AddDefine( char *, char * ); /* Add new #define to a linked list */
|
||||
|
||||
extern int hb_pp_lInclude;
|
||||
extern int * hb_pp_aCondCompile;
|
||||
extern int hb_pp_nCondCompile;
|
||||
extern char * hb_pp_szErrors[];
|
||||
extern char * hb_pp_szWarnings[];
|
||||
extern int hb_pp_nEmptyStrings;
|
||||
extern int hb_pp_LastOutLine;
|
||||
extern int hb_pp_StreamBlock;
|
||||
extern BOOL hb_pp_NestedLiteralString;
|
||||
extern BOOL hb_pp_LiteralEscSeq;
|
||||
extern unsigned int hb_pp_MaxTranslateCycles;
|
||||
|
||||
/* PPCOMP.C exported functions */
|
||||
|
||||
extern int hb_pp_Internal( FILE *, char * );
|
||||
extern void hb_pp_InternalFree( void );
|
||||
|
||||
#define HB_PP_STREAM_DUMP_C 1 /* pragma BEGINDUMP */
|
||||
#define HB_PP_STREAM_CLIPPER 2 /* clipper compatible TEXT/ENDTEXT */
|
||||
/* #pragma {__text,__stream,__cstream}|functionOut|functionEnd|functionStart */
|
||||
#define HB_PP_STREAM_OFF 0 /* standard preprocessing */
|
||||
#define HB_PP_STREAM_COMMENT 1 /* multiline comment */
|
||||
#define HB_PP_STREAM_DUMP_C 2 /* pragma BEGINDUMP */
|
||||
#define HB_PP_STREAM_CLIPPER 3 /* clipper compatible TEXT/ENDTEXT */
|
||||
#define HB_PP_STREAM_PRG 4 /* TEXT/ENDTEXT lines joined with LF */
|
||||
#define HB_PP_STREAM_C 8 /* TEXT/ENDTEXT lines joined and ESC seq processed */
|
||||
#define HB_PP_STREAM_C 5 /* TEXT/ENDTEXT lines joined and ESC seq processed */
|
||||
|
||||
extern BOOL hb_pp_StreamBlockBegin( char *, int );
|
||||
extern void hb_pp_BlockEnd( void );
|
||||
|
||||
/* PPTABLE.C exported functions and variables */
|
||||
/* function to open included files */
|
||||
#define HB_PP_OPEN_FUNC_( func ) FILE * func( char *, BOOL, char * )
|
||||
typedef HB_PP_OPEN_FUNC_( HB_PP_OPEN_FUNC );
|
||||
typedef HB_PP_OPEN_FUNC * PHB_PP_OPEN_FUNC;
|
||||
|
||||
extern void hb_pp_Table( void );
|
||||
/* function to close included files */
|
||||
#define HB_PP_CLOSE_FUNC_( func ) void func( FILE * )
|
||||
typedef HB_PP_CLOSE_FUNC_( HB_PP_CLOSE_FUNC );
|
||||
typedef HB_PP_CLOSE_FUNC * PHB_PP_CLOSE_FUNC;
|
||||
|
||||
extern DEFINES * hb_pp_topDefine;
|
||||
extern COMMANDS * hb_pp_topCommand;
|
||||
extern COMMANDS * hb_pp_topTranslate;
|
||||
/* function to generate errors */
|
||||
#define HB_PP_ERROR_FUNC_( func ) void func( char **, char, int, const char *, const char * )
|
||||
typedef HB_PP_ERROR_FUNC_( HB_PP_ERROR_FUNC );
|
||||
typedef HB_PP_ERROR_FUNC * PHB_PP_ERROR_FUNC;
|
||||
|
||||
/* PRAGMA.C exported functions */
|
||||
/* function to redirect stdout messages */
|
||||
#define HB_PP_DISP_FUNC_( func ) void func( const char * )
|
||||
typedef HB_PP_DISP_FUNC_( HB_PP_DISP_FUNC );
|
||||
typedef HB_PP_DISP_FUNC * PHB_PP_DISP_FUNC;
|
||||
|
||||
extern BOOL hb_pp_ParsePragma( char * szline );
|
||||
/* function for catching #pragma dump data */
|
||||
#define HB_PP_DUMP_FUNC_( func ) void func( char *, ULONG, int )
|
||||
typedef HB_PP_DUMP_FUNC_( HB_PP_DUMP_FUNC );
|
||||
typedef HB_PP_DUMP_FUNC * PHB_PP_DUMP_FUNC;
|
||||
|
||||
/* function for catching #pragma dump data */
|
||||
#define HB_PP_SWITCH_FUNC_( func ) BOOL func( const char *, int )
|
||||
typedef HB_PP_SWITCH_FUNC_( HB_PP_SWITCH_FUNC );
|
||||
typedef HB_PP_SWITCH_FUNC * PHB_PP_SWITCH_FUNC;
|
||||
|
||||
|
||||
#ifdef _HB_PP_INTERNAL
|
||||
|
||||
/* default maximum number of translations */
|
||||
#define HB_PP_MAX_CYCLES 4096
|
||||
/* maximum number of single token translations, in Clipper it's 18 + number
|
||||
of used rules, we will use also constant but increased by total number
|
||||
of rules of given type: define, [x]translate, [x]command */
|
||||
#define HB_PP_MAX_REPATS 128
|
||||
|
||||
/* Clipper allows only 16 nested includes */
|
||||
#define HB_PP_MAX_INCLUDED_FILES 64
|
||||
|
||||
|
||||
/* comparision modes */
|
||||
#define HB_PP_CMP_ADDR 0 /* compare token addresses */
|
||||
#define HB_PP_CMP_STD 1 /* standard comparison, ignore the case of the characters */
|
||||
#define HB_PP_CMP_DBASE 2 /* dbase keyword comparison (accepts at least four character shortcuts) ignore the case of the characters */
|
||||
#define HB_PP_CMP_CASE 3 /* case sensitive comparison */
|
||||
|
||||
#define HB_PP_CMP_MODE(t) ( (t) & 0xff )
|
||||
#define HB_PP_STD_RULE 0x8000
|
||||
|
||||
|
||||
/* conditional compilation */
|
||||
#define HB_PP_COND_ELSE 1 /* preprocessing and output stopped until corresponding #else */
|
||||
#define HB_PP_COND_DISABLE 2 /* preprocessing and output stopped until corresponding #endif(s) */
|
||||
|
||||
/* operation precedence for #if calculation */
|
||||
#define HB_PP_PREC_NUL 0
|
||||
#define HB_PP_PREC_NOT 1
|
||||
#define HB_PP_PREC_LOG 2
|
||||
#define HB_PP_PREC_REL 3
|
||||
#define HB_PP_PREC_BIT 4
|
||||
#define HB_PP_PREC_PLUS 5
|
||||
#define HB_PP_PREC_MULT 6
|
||||
#define HB_PP_PREC_NEG 7
|
||||
|
||||
|
||||
/* preprocessor tokens */
|
||||
#define HB_PP_TOKEN_NUL 0
|
||||
|
||||
#define HB_PP_MMARKER_REGULAR 1
|
||||
#define HB_PP_MMARKER_LIST 2
|
||||
#define HB_PP_MMARKER_RESTRICT 3
|
||||
#define HB_PP_MMARKER_WILD 4
|
||||
#define HB_PP_MMARKER_EXTEXP 5
|
||||
#define HB_PP_MMARKER_NAME 6
|
||||
#define HB_PP_MMARKER_OPTIONAL 7
|
||||
|
||||
#define HB_PP_RMARKER_REGULAR 11
|
||||
#define HB_PP_RMARKER_STRDUMP 12
|
||||
#define HB_PP_RMARKER_STRSTD 13
|
||||
#define HB_PP_RMARKER_STRSMART 14
|
||||
#define HB_PP_RMARKER_BLOCK 15
|
||||
#define HB_PP_RMARKER_LOGICAL 16
|
||||
#define HB_PP_RMARKER_NUL 17
|
||||
#define HB_PP_RMARKER_OPTIONAL 18
|
||||
|
||||
/* keywords, pseudo keywords and PP only tokens */
|
||||
#define HB_PP_TOKEN_KEYWORD 21
|
||||
#define HB_PP_TOKEN_MACRO 22
|
||||
#define HB_PP_TOKEN_TEXT 23
|
||||
#define HB_PP_TOKEN_OTHER 24 /* non keyword, text, or operator character */
|
||||
#define HB_PP_TOKEN_BACKSLASH 25 /* "\\" */
|
||||
#define HB_PP_TOKEN_PIPE 26 /* "|" */
|
||||
#define HB_PP_TOKEN_DOT 27 /* "." */
|
||||
#define HB_PP_TOKEN_COMMA 28 /* "," */
|
||||
#define HB_PP_TOKEN_EOC 29 /* ";" */
|
||||
#define HB_PP_TOKEN_EOL 30 /* "\n" */
|
||||
#define HB_PP_TOKEN_HASH 31 /* "\n" */
|
||||
#define HB_PP_TOKEN_DIRECTIVE 32 /* direct # directive first token */
|
||||
|
||||
/* constant values */
|
||||
#define HB_PP_TOKEN_STRING 41
|
||||
#define HB_PP_TOKEN_NUMBER 42
|
||||
#define HB_PP_TOKEN_DATE 43
|
||||
#define HB_PP_TOKEN_LOGICAL 44
|
||||
|
||||
/* operators */
|
||||
#define HB_PP_TOKEN_LEFT_PB 50
|
||||
#define HB_PP_TOKEN_RIGHT_PB 51
|
||||
#define HB_PP_TOKEN_LEFT_SB 52
|
||||
#define HB_PP_TOKEN_RIGHT_SB 53
|
||||
#define HB_PP_TOKEN_LEFT_CB 54
|
||||
#define HB_PP_TOKEN_RIGHT_CB 55
|
||||
#define HB_PP_TOKEN_REFERENCE 56
|
||||
#define HB_PP_TOKEN_AMPERSAND 57
|
||||
#define HB_PP_TOKEN_SEND 58
|
||||
#define HB_PP_TOKEN_ALIAS 59
|
||||
|
||||
#define HB_PP_TOKEN_ASSIGN 60
|
||||
#define HB_PP_TOKEN_PLUSEQ 61
|
||||
#define HB_PP_TOKEN_MINUSEQ 62
|
||||
#define HB_PP_TOKEN_MULTEQ 63
|
||||
#define HB_PP_TOKEN_DIVEQ 64
|
||||
#define HB_PP_TOKEN_MODEQ 65
|
||||
#define HB_PP_TOKEN_EXPEQ 66
|
||||
|
||||
#define HB_PP_TOKEN_INC 67
|
||||
#define HB_PP_TOKEN_DEC 68
|
||||
#define HB_PP_TOKEN_NOT 69
|
||||
#define HB_PP_TOKEN_OR 70
|
||||
#define HB_PP_TOKEN_AND 71
|
||||
#define HB_PP_TOKEN_EQUAL 72
|
||||
#define HB_PP_TOKEN_EQ 73
|
||||
#define HB_PP_TOKEN_LT 74
|
||||
#define HB_PP_TOKEN_GT 75
|
||||
#define HB_PP_TOKEN_LE 76
|
||||
#define HB_PP_TOKEN_GE 77
|
||||
#define HB_PP_TOKEN_NE 78
|
||||
#define HB_PP_TOKEN_IN 79
|
||||
#define HB_PP_TOKEN_PLUS 80
|
||||
#define HB_PP_TOKEN_MINUS 81
|
||||
#define HB_PP_TOKEN_MULT 82
|
||||
#define HB_PP_TOKEN_DIV 83
|
||||
#define HB_PP_TOKEN_MOD 84
|
||||
#define HB_PP_TOKEN_POWER 85
|
||||
|
||||
|
||||
/* bitfields */
|
||||
//#define HB_PP_TOKEN_UNARY 0x0100
|
||||
//#define HB_PP_TOKEN_BINARY 0x0200
|
||||
//#define HB_PP_TOKEN_JOINABLE 0x0400
|
||||
#define HB_PP_TOKEN_MATCHMARKER 0x2000
|
||||
#define HB_PP_TOKEN_STATIC 0x4000
|
||||
#define HB_PP_TOKEN_PREDEFINED 0x8000
|
||||
|
||||
#define HB_PP_TOKEN_SETTYPE(t,n) do{ (t)->type = ( (t)->type & 0xff00 ) | (n); } while(0)
|
||||
|
||||
#define HB_PP_TOKEN_TYPE(t) ( (t) & 0xff )
|
||||
#define HB_PP_TOKEN_ALLOC(t) ( ( (t) & HB_PP_TOKEN_STATIC ) == 0 )
|
||||
#define HB_PP_TOKEN_ISPREDEF(t) ( ( (t)->type & HB_PP_TOKEN_PREDEFINED ) != 0 )
|
||||
|
||||
/* These macros are very important for the PP behavior. They define what
|
||||
and how will be translated. Their default definitions are not strictly
|
||||
Clipper compatible to allow programmer using indirect # directive
|
||||
EOL - end of line => '\n' or NULL
|
||||
EOC - end of command => EOL or ';'
|
||||
EOS - end of subst => EOL or ';' + '#'
|
||||
EOP - end of pattern => EOL for direct and EOC for indirect
|
||||
*/
|
||||
|
||||
/* End Of Line */
|
||||
#define HB_PP_TOKEN_ISEOL(t) ( (t) == NULL || \
|
||||
HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_EOL )
|
||||
/* End Of Command */
|
||||
#define HB_PP_TOKEN_ISEOC(t) ( HB_PP_TOKEN_ISEOL(t) || \
|
||||
HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_EOC )
|
||||
|
||||
#ifdef HB_C52_STRICT
|
||||
# define HB_PP_TOKEN_ISEOS(t) HB_PP_TOKEN_ISEOL(t)
|
||||
# define HB_PP_TOKEN_ISEOP(t,l) HB_PP_TOKEN_ISEOL(t)
|
||||
#else
|
||||
/* End Of Subst - define how mant tokens in line should be translated,
|
||||
Clipper translate whole line */
|
||||
# define HB_PP_TOKEN_ISEOS(t) ( HB_PP_TOKEN_ISEOL(t) || \
|
||||
( HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_EOC && \
|
||||
(t)->pNext && \
|
||||
( HB_PP_TOKEN_TYPE((t)->pNext->type) == HB_PP_TOKEN_HASH || \
|
||||
HB_PP_TOKEN_TYPE((t)->pNext->type) == HB_PP_TOKEN_DIRECTIVE ) ) )
|
||||
/* End Of Pattern - the second paramter define if it's direct or indirect
|
||||
pattern */
|
||||
# define HB_PP_TOKEN_ISEOP(t,l) ( (l) ? HB_PP_TOKEN_ISEOL(t) : HB_PP_TOKEN_ISEOC(t) )
|
||||
#endif
|
||||
|
||||
#define HB_PP_TOKEN_ISDIRECTIVE(t) ( HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_DIRECTIVE || \
|
||||
HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_HASH )
|
||||
|
||||
#define HB_PP_TOKEN_CANJOIN(t) ( ! HB_PP_TOKEN_CLOSE_BR(t) && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_KEYWORD && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_MACRO && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_TEXT && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_STRING && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_NUMBER && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_DATE && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_LOGICAL )
|
||||
|
||||
#define HB_PP_TOKEN_OPEN_BR(t) ( HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_LEFT_PB || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_LEFT_SB || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_LEFT_CB )
|
||||
|
||||
#define HB_PP_TOKEN_CLOSE_BR(t) ( HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_RIGHT_PB || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_RIGHT_SB || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_RIGHT_CB )
|
||||
|
||||
#define HB_PP_TOKEN_NEEDLEFT(t) ( HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_ASSIGN || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_PLUSEQ || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_MINUSEQ || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_MULTEQ || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_DIVEQ || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_MODEQ || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_EXPEQ || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_EQUAL || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_EQ || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_LEFT_SB )
|
||||
|
||||
/* I do not want to replicate exactly Clipper PP behavior and check if
|
||||
expression is valid.
|
||||
it's wrong and causes that potentially valid expressions are not
|
||||
properly parsed, f.e:
|
||||
? 1 + + 2
|
||||
does not work when
|
||||
qout( 1 + + 2 )
|
||||
perfectly does.
|
||||
It this difference will be reason of some problems then please inform me
|
||||
with a code example so I'll be able if it should be implemented or not.
|
||||
Now I simply disabled HB_PP_TOKEN_NEEDRIGHT() macro.
|
||||
*/
|
||||
#ifndef HB_C52_STRICT
|
||||
#define HB_PP_TOKEN_NEEDRIGHT(t) ( FALSE )
|
||||
#else
|
||||
#define HB_PP_TOKEN_NEEDRIGHT(t) ( HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_PLUS || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_MINUS || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_MULT || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_DIV || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_MOD || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_POWER )
|
||||
#endif
|
||||
|
||||
#ifdef HB_C52_STRICT
|
||||
# define HB_PP_TOKEN_ISUNARY(t) ( HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_MINUS || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_DEC || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_INC || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_AMPERSAND )
|
||||
#else
|
||||
# define HB_PP_TOKEN_ISUNARY(t) ( HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_MINUS || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_DEC || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_INC || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_AMPERSAND || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_PLUS || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_NOT || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_REFERENCE )
|
||||
#endif
|
||||
|
||||
#define HB_PP_TOKEN_ISMATCH(t) ( (t) && ( (t)->type & HB_PP_TOKEN_MATCHMARKER ) != 0 )
|
||||
|
||||
#if 0
|
||||
#define HB_PP_TOKEN_ISRESULT(t) ( HB_PP_TOKEN_TYPE(t) == HB_PP_RMARKER_REGULAR || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_RMARKER_STRDUMP || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_RMARKER_STRSTD || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_RMARKER_STRSMART || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_RMARKER_BLOCK || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_RMARKER_LOGICAL || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_RMARKER_NUL )
|
||||
#endif
|
||||
|
||||
#define HB_PP_TOKEN_ISEXPVAL(t) ( HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_KEYWORD || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_MACRO || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_STRING || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_NUMBER || \
|
||||
HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_DATE )
|
||||
#define HB_PP_TOKEN_ISEXPTOKEN(t) ( HB_PP_TOKEN_ISEXPVAL( (t)->type ) || \
|
||||
( (t)->pNext && HB_PP_TOKEN_ISUNARY( (t)->type ) && \
|
||||
HB_PP_TOKEN_ISEXPVAL( (t)->pNext->type ) ) )
|
||||
|
||||
#ifdef HB_C52_STRICT
|
||||
/* Clipper supports quoting by [] for 1-st token in the line so we
|
||||
are checking for HB_PP_TOKEN_NUL in this macro */
|
||||
#define HB_PP_TOKEN_CANQUOTE(t) ( HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_NUL && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_KEYWORD && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_MACRO && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_RIGHT_PB && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_RIGHT_SB && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_RIGHT_CB )
|
||||
#else
|
||||
/* Disable string quoting by [] for next token if current one is
|
||||
constant value - it's not Clipper compatible but we need it for
|
||||
accessing string characters by array index operator or introduce
|
||||
similar extensions in the future */
|
||||
#define HB_PP_TOKEN_CANQUOTE(t) ( HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_NUL && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_KEYWORD && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_MACRO && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_RIGHT_PB && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_RIGHT_SB && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_RIGHT_CB && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_STRING && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_NUMBER && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_DATE && \
|
||||
HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_LOGICAL )
|
||||
#endif
|
||||
/* For platforms which does not use ASCII based character tables this macros
|
||||
have to be changed to use valid C functions, f.e.:
|
||||
isalpha(), isdigit(), ... */
|
||||
#ifdef HB_C52_STRICT
|
||||
# define HB_PP_ISILLEGAL(c) ( (c) < 32 || (c) >= 126 )
|
||||
#else
|
||||
# define HB_PP_ISILLEGAL(c) ( (c) < 32 || (c) == 127 )
|
||||
#endif
|
||||
#define HB_PP_ISTEXTCHAR(c) ( (unsigned char) (c) >= 128 )
|
||||
#define HB_PP_ISBLANK(c) ( (c) == ' ' || (c) == '\t' )
|
||||
#define HB_PP_ISDIGIT(c) ( (c) >= '0' && (c) <= '9' )
|
||||
#define HB_PP_ISHEX(c) ( HB_PP_ISDIGIT(c) || \
|
||||
( (c) >= 'A' && (c) <= 'F' ) || \
|
||||
( (c) >= 'a' && (c) <= 'f' ) )
|
||||
#define HB_PP_ISTRUE(c) ( (c) == 'T' || (c) == 't' || \
|
||||
(c) == 'Y' || (c) == 'y' )
|
||||
#define HB_PP_ISFALSE(c) ( (c) == 'F' || (c) == 'f' || \
|
||||
(c) == 'N' || (c) == 'n' )
|
||||
#define HB_PP_ISFIRSTIDCHAR(c) ( ( (c) >= 'A' && (c) <= 'Z' ) || \
|
||||
( (c) >= 'a' && (c) <= 'z' ) || (c) == '_' )
|
||||
#define HB_PP_ISNEXTIDCHAR(c) ( HB_PP_ISFIRSTIDCHAR(c) || HB_PP_ISDIGIT(c) )
|
||||
|
||||
typedef struct _HB_PP_TOKEN
|
||||
{
|
||||
struct _HB_PP_TOKEN * pNext; /* next token pointer */
|
||||
struct _HB_PP_TOKEN * pMTokens; /* restrict or optional marker token(s) */
|
||||
|
||||
char * value; /* token value */
|
||||
USHORT len; /* token value length */
|
||||
USHORT spaces; /* leading spaces for stringify */
|
||||
USHORT type; /* token type, see HB_PP_TOKEN_* */
|
||||
USHORT index; /* index to match marker or 0 */
|
||||
}
|
||||
HB_PP_TOKEN, * PHB_PP_TOKEN;
|
||||
|
||||
typedef struct _HB_PP_RESULT
|
||||
{
|
||||
struct _HB_PP_RESULT * pNext;
|
||||
PHB_PP_TOKEN pFirstToken;
|
||||
PHB_PP_TOKEN pNextExpr;
|
||||
}
|
||||
HB_PP_RESULT, * PHB_PP_RESULT;
|
||||
|
||||
typedef struct _HB_PP_MARKERPTR
|
||||
{
|
||||
struct _HB_PP_MARKERPTR * pNext;
|
||||
PHB_PP_TOKEN pToken;
|
||||
PHB_PP_TOKEN pMTokens;
|
||||
USHORT type;
|
||||
}
|
||||
HB_PP_MARKERPTR, * PHB_PP_MARKERPTR;
|
||||
|
||||
typedef struct _HB_PP_MARKERLST
|
||||
{
|
||||
struct _HB_PP_MARKERLST * pNext;
|
||||
PHB_PP_MARKERPTR pMatchMarkers;
|
||||
USHORT canrepeat;
|
||||
USHORT index;
|
||||
}
|
||||
HB_PP_MARKERLST, * PHB_PP_MARKERLST;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
USHORT canrepeat;
|
||||
/* filled when pattern matches for substitution, cleared after */
|
||||
USHORT matches;
|
||||
PHB_PP_RESULT pResult;
|
||||
}
|
||||
HB_PP_MARKER, * PHB_PP_MARKER;
|
||||
|
||||
typedef struct _HB_PP_RULE
|
||||
{
|
||||
struct _HB_PP_RULE * pPrev; /* previous rule */
|
||||
PHB_PP_TOKEN pMatch; /* match patern or NULL */
|
||||
PHB_PP_TOKEN pResult; /* result patern or NULL */
|
||||
USHORT mode; /* comparison mode HB_PP_CMP_* */
|
||||
USHORT markers; /* number of markers in marker table */
|
||||
/* filled when pattern matches for substitution, cleared after */
|
||||
PHB_PP_MARKER pMarkers; /* marker table */
|
||||
PHB_PP_TOKEN pNextExpr; /* next expression after match pattern */
|
||||
}
|
||||
HB_PP_RULE, * PHB_PP_RULE;
|
||||
|
||||
typedef struct _HB_PP_DEFRULE
|
||||
{
|
||||
PHB_PP_TOKEN pMatch;
|
||||
PHB_PP_TOKEN pResult;
|
||||
USHORT mode;
|
||||
USHORT markers;
|
||||
ULONG repeatbits;
|
||||
}
|
||||
HB_PP_DEFRULE, * PHB_PP_DEFRULE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char * name; /* input name */
|
||||
ULONG len; /* input name length */
|
||||
char * value; /* output name */
|
||||
USHORT type; /* HB_PP_TOKEN_* */
|
||||
}
|
||||
HB_PP_OPERATOR, * PHB_PP_OPERATOR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char * pBufPtr;
|
||||
ULONG ulLen;
|
||||
ULONG ulAllocated;
|
||||
}
|
||||
HB_MEM_BUFFER, * PHB_MEM_BUFFER;
|
||||
|
||||
typedef struct _HB_PP_FILE
|
||||
{
|
||||
char * szFileName; /* input file name */
|
||||
FILE * file_in; /* input file handle */
|
||||
PHB_PP_TOKEN pTokenList; /* current line decoded to tokens */
|
||||
int iCurrentLine; /* current line in file */
|
||||
int iLastLine; /* last non empty generated line */
|
||||
int iLastDisp; /* last shown line number */
|
||||
int iTokens; /* number of decoded tokens */
|
||||
BOOL fGenLineInfo; /* #line information should be generated */
|
||||
BOOL fEof; /* the end of file reached */
|
||||
|
||||
char * pLineBuf; /* buffer for parsing external lines */
|
||||
ULONG ulLineBufLen; /* size of external line buffer */
|
||||
|
||||
struct _HB_PP_FILE * pPrev; /* previous file, the one which included this file */
|
||||
}
|
||||
HB_PP_FILE, * PHB_PP_FILE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* common for all included files */
|
||||
PHB_PP_OPERATOR pOperators; /* user defined operators */
|
||||
PHB_PP_RULE pDefinitions; /* #define table */
|
||||
PHB_PP_RULE pTranslations; /* #[x]translate table */
|
||||
PHB_PP_RULE pCommands; /* #[x]command table */
|
||||
int iOperators; /* number of user defined operators */
|
||||
int iDefinitions; /* number of rules in pDefinitions */
|
||||
int iTranslations; /* number of rules in pTranslations */
|
||||
int iCommands; /* number of rules in pCommands */
|
||||
|
||||
PHB_PP_TOKEN pTokenOut; /* preprocessed tokens */
|
||||
PHB_PP_TOKEN * pNextTokenPtr; /* pointer to the last NULL pointer in token list */
|
||||
|
||||
PHB_MEM_BUFFER pDumpBuffer; /* buffer for dump output */
|
||||
PHB_MEM_BUFFER pOutputBuffer; /* buffer for preprocessed line */
|
||||
|
||||
int iCycle; /* translation counter */
|
||||
int iMaxCycles; /* maximum number of translations */
|
||||
int iHideStrings; /* hidden string mode */
|
||||
BOOL fTracePragmas; /* display information about set pragmas */
|
||||
BOOL fWritePreprocesed; /* write preprocessed data to file (.ppo) */
|
||||
|
||||
HB_PATHNAMES * pIncludePath; /* search path(s) for included files */
|
||||
|
||||
char * szOutFileName; /* output file name */
|
||||
FILE * file_out; /* output file handle */
|
||||
|
||||
BOOL fError; /* error during preprocessing */
|
||||
BOOL fQuiet; /* do not show standard information */
|
||||
int iCondCompile; /* current conditional compilation flag, when not 0 disable preprocessing and output */
|
||||
int iCondCount; /* number of nested #if[n]def directive */
|
||||
int iCondStackSize; /* size of conditional compilation stack */
|
||||
int * pCondStack; /* conditional compilation stack */
|
||||
FILE * file_in; /* file handle */
|
||||
|
||||
/* used to divide line per tokens and tokens manipulations */
|
||||
PHB_MEM_BUFFER pBuffer; /* buffer for input and output line */
|
||||
int iSpaces; /* leading spaces for next token */
|
||||
int iSpacesNL; /* leading spaces ';' token (fCanNextLine) if it will not be line concatenator */
|
||||
int iLastType; /* last token type */
|
||||
BOOL fCanNextLine; /* ';' token found and we do not know yet if it's command separator or line concatenator */
|
||||
BOOL fDirective; /* # directives is parsed */
|
||||
BOOL fNewStatement; /* set to TRUE at line begining or after each ';' token */
|
||||
PHB_PP_TOKEN pFuncOut; /* function used for each line in HB_PP_STREAM_* dumping */
|
||||
PHB_PP_TOKEN pFuncEnd; /* end function for HB_PP_STREAM_* dumping */
|
||||
PHB_MEM_BUFFER pStreamBuffer; /* buffer for stream output */
|
||||
int iStreamDump; /* stream output, see HB_PP_STREAM_* */
|
||||
int iDumpLine; /* line where current dump output begins */
|
||||
|
||||
PHB_PP_FILE pFile; /* currently preprocessed file structure */
|
||||
int iFiles; /* number of open files */
|
||||
|
||||
PHB_PP_OPEN_FUNC pOpenFunc; /* function to open files */
|
||||
PHB_PP_CLOSE_FUNC pCloseFunc; /* function to close files */
|
||||
PHB_PP_ERROR_FUNC pErrorFunc; /* function to generate errors */
|
||||
PHB_PP_DISP_FUNC pDispFunc; /* function to redirect stdout messages */
|
||||
PHB_PP_DUMP_FUNC pDumpFunc; /* function for catching #pragma dump data */
|
||||
PHB_PP_SWITCH_FUNC pSwitchFunc; /* function to compiler switches with #pragma ... */
|
||||
}
|
||||
HB_PP_STATE, * PHB_PP_STATE;
|
||||
|
||||
extern void hb_pp_initRules( PHB_PP_RULE * pRulesPtr, int * piRules,
|
||||
const HB_PP_DEFRULE pDefRules[], int iDefRules );
|
||||
|
||||
extern void hb_pp_initStaticRules( PHB_PP_STATE pState );
|
||||
|
||||
#else
|
||||
|
||||
typedef void * PHB_PP_STATE;
|
||||
|
||||
#endif /* _HB_PP_INTERNAL */
|
||||
|
||||
/* public functions */
|
||||
extern PHB_PP_STATE hb_pp_new( void );
|
||||
extern void hb_pp_init( PHB_PP_STATE pState, char * szFileName, BOOL fQuiet,
|
||||
PHB_PP_OPEN_FUNC pOpenFunc, PHB_PP_CLOSE_FUNC pCloseFunc,
|
||||
PHB_PP_ERROR_FUNC pErrorFunc, PHB_PP_DISP_FUNC pDispFunc,
|
||||
PHB_PP_DUMP_FUNC pDumpFunc, PHB_PP_SWITCH_FUNC pSwitchFunc );
|
||||
extern void hb_pp_free( PHB_PP_STATE pState );
|
||||
extern void hb_pp_reset( PHB_PP_STATE pState );
|
||||
extern void hb_pp_setStdBase( PHB_PP_STATE pState );
|
||||
extern void hb_pp_addSearchPath( PHB_PP_STATE pState, const char * szPath, BOOL fReplace );
|
||||
extern void hb_pp_inFile( PHB_PP_STATE pState, char * szFileName, FILE * file_in );
|
||||
extern void hb_pp_outFile( PHB_PP_STATE pState, char * szOutFileName, FILE * file_out );
|
||||
extern char * hb_pp_fileName( PHB_PP_STATE pState );
|
||||
extern int hb_pp_line( PHB_PP_STATE pState );
|
||||
extern char * hb_pp_outFileName( PHB_PP_STATE pState );
|
||||
extern char * hb_pp_nextLine( PHB_PP_STATE pState, ULONG * pulLen );
|
||||
extern char * hb_pp_parseLine( PHB_PP_STATE pState, char * pLine, ULONG * pulLen );
|
||||
extern void hb_pp_addDefine( PHB_PP_STATE pState, char * szDefName, char * szDefValue );
|
||||
extern void hb_pp_delDefine( PHB_PP_STATE pState, char * szDefName );
|
||||
|
||||
HB_EXTERN_END
|
||||
|
||||
#endif /* HB_PP_H_ */
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ typedef struct _CDXTAG
|
||||
|
||||
BOOL UsrAscend; /* user settable ascending/descending order flag */
|
||||
BOOL UsrUnique; /* user settable unique order flag */
|
||||
|
||||
|
||||
BOOL TagChanged;
|
||||
BOOL TagBOF;
|
||||
BOOL TagEOF;
|
||||
|
||||
@@ -82,7 +82,4 @@
|
||||
|
||||
/* #define HB_FILE_VER_STATIC */ /* Enable inclusion of file version strings */
|
||||
|
||||
/*#define HB_CLS_ENFORCERO */ /* Activate the RO checking on OO DATA */
|
||||
/* when not called from a constructor */
|
||||
|
||||
#endif /* HB_SETUP_CH_ */
|
||||
|
||||
86
harbour/include/hbstdgen.ch
Normal file
86
harbour/include/hbstdgen.ch
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
*
|
||||
*
|
||||
* Copyright 2006 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* include hbsetup.ch to set default build settings */
|
||||
#include "hbsetup.ch"
|
||||
/* include std.ch to set default rules */
|
||||
#include "std.ch"
|
||||
|
||||
/* undefine all rules which are not necessary in default PP tables */
|
||||
#undef HB_SETUP_CH_
|
||||
|
||||
#undef HB_EXTENSION
|
||||
|
||||
#undef HB_C52_UNDOC
|
||||
#undef HB_C52_STRICT
|
||||
|
||||
#undef HB_COMPAT_C53
|
||||
#undef HB_COMPAT_XPP
|
||||
#undef HB_COMPAT_VO
|
||||
#undef HB_COMPAT_FLAGSHIP
|
||||
#undef HB_COMPAT_FOXPRO
|
||||
#undef HB_COMPAT_DBASE
|
||||
#undef HB_COMPAT_CLIP
|
||||
|
||||
#undef HB_SHORTNAMES
|
||||
#undef HB_FILE_VER_STATIC
|
||||
|
||||
#undef __HARBOUR__
|
||||
#undef __DATE__
|
||||
#undef __TIME__
|
||||
#undef __HB_MAIN__
|
||||
#undef __ARCH16BIT__
|
||||
#undef __ARCH32BIT__
|
||||
#undef __ARCH64BIT__
|
||||
#undef __LITTLE_ENDIAN__
|
||||
#undef __BIG_ENDIAN__
|
||||
#undef __PDP_ENDIAN__
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Header file for the standard command definitions.
|
||||
*
|
||||
*
|
||||
* Copyright 1999 {list of individual authors and e-mail addresses}
|
||||
* Copyright 2006 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -55,6 +55,605 @@
|
||||
|
||||
#include "set.ch"
|
||||
|
||||
/* TODO: Fill this file. */
|
||||
#command DO WHILE <exp> => while <exp>
|
||||
#command END <x> => end
|
||||
#command END SEQUENCE => end
|
||||
#command ENDSEQUENCE => end
|
||||
#command ENDDO <*x*> => enddo
|
||||
#command ENDIF <*x*> => endif
|
||||
#command ENDCASE <*x*> => endcase
|
||||
#command ENDFOR [<*x*>] => next
|
||||
#command NEXT <v> [TO <x>] [STEP <s>] => next
|
||||
#command DO <proc>.prg [WITH <p,...>] => do <proc> [ WITH <p>]
|
||||
#command CALL <proc>() [WITH <p,...>] => call <proc> [ WITH <p>]
|
||||
#command STORE <v> TO <v1> [,<vN>] => <v1> := [ <vN> :=] <v>
|
||||
|
||||
#command SET ECHO <*x*> =>
|
||||
#command SET HEADING <*x*> =>
|
||||
#command SET MENU <*x*> =>
|
||||
#command SET STATUS <*x*> =>
|
||||
#command SET STEP <*x*> =>
|
||||
#command SET SAFETY <*x*> =>
|
||||
#command SET TALK <*x*> =>
|
||||
#command SET PROCEDURE TO =>
|
||||
#command SET PROCEDURE TO <f> => _ProcReq_( <(f)> )
|
||||
#command SET FORMAT TO <id> => ;
|
||||
_ProcReq_( <(id)> + ".fmt" ) ; __SetFormat( {|| <id>()} )
|
||||
#command SET FORMAT TO <id>.<ext> => ;
|
||||
_ProcReq_( <(id)> + "." + <(ext)> ) ; __SetFormat( {|| <id>()} )
|
||||
#command SET FORMAT TO <id:&> => ;
|
||||
if ( Empty(<(id)>) ) ; SET FORMAT TO ; else ;;
|
||||
__SetFormat( &("{||" + <(id)> + "()}") ) ; end
|
||||
#command SET FORMAT TO => __SetFormat()
|
||||
|
||||
#define _DFSET(x, y) Set( _SET_DATEFORMAT, if(__SetCentury(), x, y) )
|
||||
#command SET DATE [TO] AMERICAN => _DFSET( "mm/dd/yyyy", "mm/dd/yy" )
|
||||
#command SET DATE [TO] ANSI => _DFSET( "yyyy.mm.dd", "yy.mm.dd" )
|
||||
#command SET DATE [TO] BRITISH => _DFSET( "dd/mm/yyyy", "dd/mm/yy" )
|
||||
#command SET DATE [TO] FRENCH => _DFSET( "dd/mm/yyyy", "dd/mm/yy" )
|
||||
#command SET DATE [TO] GERMAN => _DFSET( "dd.mm.yyyy", "dd.mm.yy" )
|
||||
#command SET DATE [TO] ITALIAN => _DFSET( "dd-mm-yyyy", "dd-mm-yy" )
|
||||
#command SET DATE [TO] JAPANESE => _DFSET( "yyyy/mm/dd", "yy/mm/dd" )
|
||||
#command SET DATE [TO] USA => _DFSET( "mm-dd-yyyy", "mm-dd-yy" )
|
||||
|
||||
#command SET CENTURY <x:ON,OFF,&> => __SetCentury( <(x)> )
|
||||
#command SET CENTURY (<x>) => __SetCentury( <x> )
|
||||
#command SET DATE FORMAT [TO] <f> => Set( _SET_DATEFORMAT, <f> )
|
||||
#command SET EPOCH TO <y> => Set( _SET_EPOCH, <y> )
|
||||
|
||||
#command SET DECIMALS TO <x> => Set( _SET_DECIMALS, <x> )
|
||||
#command SET DECIMALS TO => Set( _SET_DECIMALS, 0 )
|
||||
#command SET DEFAULT TO <(path)> => Set( _SET_DEFAULT, <(path)> )
|
||||
#command SET DEFAULT TO => Set( _SET_DEFAULT, "" )
|
||||
#command SET PATH TO <*pth*> => Set( _SET_PATH, <(pth)> )
|
||||
#command SET PATH TO => Set( _SET_PATH, "" )
|
||||
|
||||
#command SET EXACT <x:ON,OFF,&> => Set( _SET_EXACT, <(x)> )
|
||||
#command SET EXACT (<x>) => Set( _SET_EXACT, <x> )
|
||||
#command SET FIXED <x:ON,OFF,&> => Set( _SET_FIXED, <(x)> )
|
||||
#command SET FIXED (<x>) => Set( _SET_FIXED, <x> )
|
||||
#command SET EXCLUSIVE <x:ON,OFF,&> => Set( _SET_EXCLUSIVE, <(x)> )
|
||||
#command SET EXCLUSIVE (<x>) => Set( _SET_EXCLUSIVE, <x> )
|
||||
#command SET SOFTSEEK <x:ON,OFF,&> => Set( _SET_SOFTSEEK, <(x)> )
|
||||
#command SET SOFTSEEK (<x>) => Set( _SET_SOFTSEEK, <x> )
|
||||
#command SET UNIQUE <x:ON,OFF,&> => Set( _SET_UNIQUE, <(x)> )
|
||||
#command SET UNIQUE (<x>) => Set( _SET_UNIQUE, <x> )
|
||||
#command SET DELETED <x:ON,OFF,&> => Set( _SET_DELETED, <(x)> )
|
||||
#command SET DELETED (<x>) => Set( _SET_DELETED, <x> )
|
||||
#command SET CONSOLE <x:ON,OFF,&> => Set( _SET_CONSOLE, <(x)> )
|
||||
#command SET CONSOLE (<x>) => Set( _SET_CONSOLE, <x> )
|
||||
#command SET BELL <x:ON,OFF,&> => Set( _SET_BELL, <(x)> )
|
||||
#command SET BELL (<x>) => Set( _SET_BELL, <x> )
|
||||
#command SET CONFIRM <x:ON,OFF,&> => Set( _SET_CONFIRM, <(x)> )
|
||||
#command SET CONFIRM (<x>) => Set( _SET_CONFIRM, <x> )
|
||||
#command SET ESCAPE <x:ON,OFF,&> => Set( _SET_ESCAPE, <(x)> )
|
||||
#command SET ESCAPE (<x>) => Set( _SET_ESCAPE, <x> )
|
||||
#command SET INTENSITY <x:ON,OFF,&> => Set( _SET_INTENSITY, <(x)> )
|
||||
#command SET INTENSITY (<x>) => Set( _SET_INTENSITY, <x> )
|
||||
#command SET SCOREBOARD <x:ON,OFF,&> => Set( _SET_SCOREBOARD, <(x)> )
|
||||
#command SET SCOREBOARD (<x>) => Set( _SET_SCOREBOARD, <x> )
|
||||
#command SET WRAP <x:ON,OFF,&> => Set( _SET_WRAP, <(x)> )
|
||||
#command SET WRAP (<x>) => Set( _SET_WRAP, <x> )
|
||||
#command SET DELIMITERS <x:ON,OFF,&> => Set( _SET_DELIMITERS, <(x)> )
|
||||
#command SET DELIMITERS (<x>) => Set( _SET_DELIMITERS, <x> )
|
||||
#command SET DELIMITERS TO <c> => Set( _SET_DELIMCHARS, <c> )
|
||||
#command SET DELIMITERS TO [DEFAULT] => Set( _SET_DELIMCHARS, "::" )
|
||||
#command SET ALTERNATE <x:ON,OFF,&> => Set( _SET_ALTERNATE, <(x)> )
|
||||
#command SET ALTERNATE (<x>) => Set( _SET_ALTERNATE, <x> )
|
||||
#command SET ALTERNATE TO => Set( _SET_ALTFILE, "" )
|
||||
#command SET ALTERNATE TO <(file)> [<add: ADDITIVE>] => ;
|
||||
Set( _SET_ALTFILE, <(file)>, <.add.> )
|
||||
#command SET PRINTER <x:ON,OFF,&> => Set( _SET_PRINTER, <(x)> )
|
||||
#command SET PRINTER (<x>) => Set( _SET_PRINTER, <x> )
|
||||
#command SET PRINTER TO => Set( _SET_PRINTFILE, "" )
|
||||
#command SET PRINTER TO <(file)> [<add: ADDITIVE>] => ;
|
||||
Set( _SET_PRINTFILE, <(file)>, <.add.> )
|
||||
#command SET CURSOR <x:ON,OFF,&> => ;
|
||||
SetCursor( if(Upper(<(x)>) == "ON", 1, 0) )
|
||||
#command SET CURSOR (<x>) => SetCursor( if(<x>, 1, 0) )
|
||||
#command SET MARGIN TO <x> => Set( _SET_MARGIN, <x> )
|
||||
#command SET MARGIN TO => Set( _SET_MARGIN, 0 )
|
||||
#command SET DEVICE TO SCREEN => Set( _SET_DEVICE, "SCREEN" )
|
||||
#command SET DEVICE TO PRINTER => Set( _SET_DEVICE, "PRINTER" )
|
||||
#command SET COLOR TO [<*c*>] => SetColor( #<c> )
|
||||
#command SET COLOR TO ( <c> ) => SetColor( <c> )
|
||||
#command SET COLOUR TO [<*c*>] => SET COLOR TO [<c>]
|
||||
#command SET ORDER TO <tg> [IN <(bg)>] => ordSetFocus( <tg> [, <(bg)>] )
|
||||
#command SET ORDER TO TAG <(tg)> [IN <(bg)>] => ordSetFocus( <(tg)> [, <(bg)>] )
|
||||
#command SET INDEX TO [<(i1)> [,<(iN)>]] [<add: ADDITIVE>] => ;
|
||||
if !<.add.> ; ordListClear() ; end ;
|
||||
[ ; ordListAdd( <(i1)> )] [ ; ordListAdd( <(iN)> )]
|
||||
#command SET MESSAGE TO <n> [<cent: CENTER, CENTRE>] => ;
|
||||
Set( _SET_MESSAGE, <n> ) ; Set( _SET_MCENTER, <.cent.> )
|
||||
#command SET MESSAGE TO => Set( _SET_MESSAGE, 0 ) ;;
|
||||
Set( _SET_MCENTER, .f. )
|
||||
#command SET TYPEAHEAD TO <x> => Set( _SET_TYPEAHEAD, <x> )
|
||||
#command SET KEY <n> TO <f> => SetKey( <n>, {|p, l, v| <f>(p, l, v)} )
|
||||
#command SET KEY <n> TO <f>([<p,...>]) => SET KEY <n> TO <f>
|
||||
#command SET KEY <n> TO <f:&> => ;
|
||||
if ( Empty(<(f)>) ) ; SetKey( <n>, NIL ) ; else ;;
|
||||
SetKey( <n>, {|p, l, v| <f>(p, l, v)} ) ; end
|
||||
#command SET KEY <n> [TO] => SetKey( <n>, NIL )
|
||||
#command SET FUNCTION <n> [TO] [<f>] => __SetFunction( <n>, <f> )
|
||||
|
||||
#ifdef HB_COMPAT_C53
|
||||
#command SET EVENTMASK TO <x> => Set( _SET_EVENTMASK, <x> )
|
||||
#command SET VIDEOMODE TO <x> => Set( _SET_VIDEOMODE, <x> )
|
||||
#command SET SCOPETOP TO => ordScope( 0, nil )
|
||||
#command SET SCOPETOP TO <x> => ordScope( 0, <x> )
|
||||
#command SET SCOPEBOTTOM TO => ordScope( 1, nil )
|
||||
#command SET SCOPEBOTTOM TO <x> => ordScope( 1, <x> )
|
||||
#command SET SCOPE TO => ordScope( 0, nil ) ; ordScope( 1, nil )
|
||||
#command SET SCOPE TO <x>, <y> => ordScope( 0, <x> ) ; ordScope( 1, <y> )
|
||||
#command SET SCOPE TO <x> => ordScope( 0, <x> ) ; ordScope( 1, <x> )
|
||||
#command SET SCOPE TO , <x> => ordScope( 1, <x> )
|
||||
#command SET ORDER TO => ordSetFocus( 0 )
|
||||
#command SET DESCENDING ON => ordDescend( ,, .T. )
|
||||
#command SET DESCENDING OFF => ordDescend( ,, .F. )
|
||||
#command SET AUTORDER TO => Set( _SET_AUTORDER, 0 )
|
||||
#command SET AUTORDER TO <x> => Set( _SET_AUTORDER, <x> )
|
||||
#command SET AUTOSHARE TO => Set( _SET_AUTOSHARE, 0 )
|
||||
#command SET AUTOSHARE TO <x> => Set( _SET_AUTOSHARE, <x> )
|
||||
#command SET MBLOCKSIZE TO <x> => Set( _SET_MBLOCKSIZE, <x> )
|
||||
#command SET MEMOBLOCK TO <x> => Set( _SET_MBLOCKSIZE, <x> )
|
||||
#command SET MFILEEXT TO <x> => Set( _SET_MFILEEXT, <x> )
|
||||
#command SET STRICTREAD<x:ON,OFF,&> => Set( _SET_STRICTREAD, <(x)> )
|
||||
#command SET STRICTREAD (<x>) => Set( _SET_STRICTREAD, <x> )
|
||||
#command SET OPTIMIZE <x:ON,OFF,&> => Set( _SET_OPTIMIZE, <(x)> )
|
||||
#command SET OPTIMIZE (<x>) => Set( _SET_OPTIMIZE, <x> )
|
||||
#command SET AUTOPEN <x:ON,OFF,&> => Set( _SET_AUTOPEN, <(x)> )
|
||||
#command SET AUTOPEN (<x>) => Set( _SET_AUTOPEN, <x> )
|
||||
#endif
|
||||
|
||||
#command ? [<explist,...>] => QOut( <explist> )
|
||||
#command ?? [<explist,...>] => QQOut( <explist> )
|
||||
#command EJECT => __Eject()
|
||||
#command TEXT => text QOut, QQOut
|
||||
#command TEXT TO FILE <(f)> => __TextSave( <(f)> ) ;;
|
||||
text QOut, __TextRestore
|
||||
#command TEXT TO PRINTER => __TextSave( "PRINTER" ) ;;
|
||||
text QOut, __TextRestore
|
||||
#ifdef HB_COMPAT_C53
|
||||
#xcommand TEXTBLOCK <*cText*> =>
|
||||
#endif
|
||||
|
||||
#command CLS => Scroll() ; SetPos(0,0)
|
||||
#command CLEAR SCREEN => CLS
|
||||
#command SAVE SCREEN => __XSaveScreen()
|
||||
#command RESTORE SCREEN => __XRestScreen()
|
||||
#command SAVE SCREEN TO <v> => <v> := SaveScreen( 0, 0, Maxrow(), Maxcol() )
|
||||
#command RESTORE SCREEN FROM <v> => RestScreen( 0, 0, Maxrow(), Maxcol(), <v> )
|
||||
|
||||
#command @ <row>, <col> => Scroll( <row>, <col>, <row> ) ;;
|
||||
SetPos( <row>, <col> )
|
||||
#command @ <top>, <left> CLEAR => Scroll( <top>, <left> ) ;;
|
||||
SetPos( <top>, <left> )
|
||||
#command @ <top>, <left> CLEAR TO <bottom>, <right> => ;
|
||||
Scroll( <top>, <left>, <bottom>, <right> ) ; SetPos( <top>, <left> )
|
||||
#command @ <top>, <left>, <bottom>, <right> BOX <string> [COLOR <clr>] => ;
|
||||
DispBox( <top>, <left>, <bottom>, <right>, <string> [, <clr>] )
|
||||
#command @ <top>, <left> TO <bottom>, <right> [DOUBLE] [COLOR <clr>] => ;
|
||||
DispBox( <top>, <left>, <bottom>, <right>, 2 [, <clr>] )
|
||||
#command @ <top>, <left> TO <bottom>, <right> [COLOR <clr>] => ;
|
||||
DispBox( <top>, <left>, <bottom>, <right>, 1 [, <clr>] )
|
||||
#command @ <row>, <col> SAY <exp> [PICTURE <pic>] [COLOR <clr>] => ;
|
||||
DevPos( <row>, <col> ) ; DevOutPict( <exp>, <pic> [, <clr>] )
|
||||
#command @ <row>, <col> SAY <exp> [COLOR <clr>] => ;
|
||||
DevPos( <row>, <col> ) ; DevOut( <exp> [, <clr>] )
|
||||
#command @ <row>, <col> PROMPT <prompt> [MESSAGE <msg>] => ;
|
||||
__AtPrompt( <row>, <col>, <prompt> , <msg> )
|
||||
#command MENU TO <v> => ;
|
||||
<v> := __MenuTo( {|_1| if(PCount() == 0, <v>, <v> := _1)}, #<v> )
|
||||
|
||||
#command WAIT [<msg>] => __Wait( <msg> )
|
||||
#command WAIT [<msg>] TO <v> => <v> := __Wait( <msg> )
|
||||
#command ACCEPT [<msg>] TO <v> => <v> := __Accept( <msg> )
|
||||
#command INPUT [<msg>] TO <v> => ;
|
||||
if ( !Empty(__Accept(<msg>)) ) ; <v> := &( __AcceptStr() ) ; end
|
||||
#command KEYBOARD <x> => __Keyboard( <x> )
|
||||
#command CLEAR TYPEAHEAD => __Keyboard()
|
||||
#command CLEAR MEMORY => __MVClear()
|
||||
#command RELEASE <v,...> => __MVXRelease( <"v"> )
|
||||
#command RELEASE ALL => __MVRelease( "*", .t. )
|
||||
#command RELEASE ALL LIKE <p> => __MVRelease( #<p>, .t. )
|
||||
#command RELEASE ALL EXCEPT <p> => __MVRelease( #<p>, .f. )
|
||||
#command RESTORE [FROM <(f)>] [<a:ADDITIVE>] => __MVRestore( <(f)>, <.a.> )
|
||||
#command SAVE TO <(f)> ALL LIKE <p> => __MVSave( <(f)>, <(p)>, .t. )
|
||||
#command SAVE ALL LIKE <p> TO <(f)> => __MVSave( <(f)>, <(p)>, .t. )
|
||||
#command SAVE ALL EXCEPT <p> TO <(f)> => __MVSave( <(f)>, <(p)>, .f. )
|
||||
#command SAVE TO <(f)> ALL EXCEPT <p> => __MVSave( <(f)>, <(p)>, .f. )
|
||||
#command SAVE [TO <(f)>] [ALL] => __MVSave( <(f)>, "*", .t. )
|
||||
|
||||
#command ERASE <(f)> => FErase( <(f)> )
|
||||
#command DELETE FILE <(f)> => FErase( <(f)> )
|
||||
#command RENAME <(old)> TO <(new)> => FRename( <(old)>, <(new)> )
|
||||
#command COPY FILE <(src)> TO <(dst)> => __CopyFile( <(src)>, <(dst)> )
|
||||
#command DIR [<(mask)>] => __Dir( <(mask)> )
|
||||
#command TYPE <(f)> [<prn:TO PRINTER>] [TO FILE <(dst)>] => ;
|
||||
__TypeFile( <(f)>, <.prn.> ) [ ; COPY FILE <(f)> TO <(dst)> ]
|
||||
#command TYPE <(f)> [<prn:TO PRINTER>] => __TypeFile( <(f)>, <.prn.> )
|
||||
|
||||
#command REQUEST <func,...> => EXTERNAL <func>
|
||||
#command CANCEL => __Quit()
|
||||
#command QUIT => __Quit()
|
||||
#command RUN <*cmd*> => __Run( #<cmd> )
|
||||
#command RUN ( <cmd> ) => __Run( <cmd> )
|
||||
#command ! <*cmd*> => RUN <cmd>
|
||||
#command RUN = <xpr> => ( run := <xpr> )
|
||||
#command RUN := <xpr> => ( run := <xpr> )
|
||||
|
||||
#command CLOSE <a> => <a>->( dbCloseArea() )
|
||||
#command CLOSE => dbCloseArea()
|
||||
#command CLOSE DATABASES => dbCloseAll()
|
||||
#command CLOSE ALTERNATE => Set(_SET_ALTFILE, "")
|
||||
#command CLOSE FORMAT => __SetFormat(NIL)
|
||||
#command CLOSE INDEXES => dbClearIndex()
|
||||
#command CLOSE PROCEDURE =>
|
||||
#command CLOSE ALL => CLOSE DATABASES ; SELECT 1 ; CLOSE FORMAT
|
||||
#command CLEAR => CLEAR SCREEN ; CLEAR GETS
|
||||
#command CLEAR ALL => CLOSE DATABASES ; CLOSE FORMAT ;;
|
||||
CLEAR MEMORY ; CLEAR GETS ;;
|
||||
SET ALTERNATE OFF ; SET ALTERNATE TO
|
||||
|
||||
#command SELECT <area> => dbSelectArea( <(area)> )
|
||||
#command SELECT <f>([<p,...>]) => dbSelectArea( <f>(<p>) )
|
||||
#command USE => dbCloseArea()
|
||||
#command USE <(db)> [VIA <rdd>] [ALIAS <a>] [<nw: NEW>] ;
|
||||
[<ex: EXCLUSIVE>] [<sh: SHARED>] [<ro: READONLY>] ;
|
||||
[CODEPAGE <cp>] [INDEX <(index1)> [, <(indexN)>]] => ;
|
||||
dbUseArea( <.nw.>, <rdd>, <(db)>, <(a)>, ;
|
||||
if(<.sh.> .or. <.ex.>, !<.ex.>, NIL), <.ro.> [, <cp>] ) ;
|
||||
[; dbSetIndex( <(index1)> )] ;
|
||||
[; dbSetIndex( <(indexN)> )]
|
||||
|
||||
#command APPEND BLANK => dbAppend()
|
||||
#command PACK => __dbPack()
|
||||
#command ZAP => __dbZap()
|
||||
#command UNLOCK => dbUnlock()
|
||||
#command UNLOCK ALL => dbUnlockAll()
|
||||
#command COMMIT => dbCommitAll()
|
||||
#command GOTO <x> => dbGoto(<x>)
|
||||
#command GO <x> => dbGoto(<x>)
|
||||
#command GOTO TOP => dbGoTop()
|
||||
#command GO TOP => dbGoTop()
|
||||
#command GOTO BOTTOM => dbGoBottom()
|
||||
#command GO BOTTOM => dbGoBottom()
|
||||
#command SKIP => dbSkip(1)
|
||||
#command SKIP <x> => dbSkip( <x> )
|
||||
#command SKIP ALIAS <a> => <a>->( dbSkip(1) )
|
||||
#command SKIP <x> ALIAS <a> => <a>->( dbSkip(<x>) )
|
||||
#command FIND <*text*> => dbSeek( <(text)> )
|
||||
#command FIND := <xpr> => ( find := <xpr> )
|
||||
#command FIND = <xpr> => ( find := <xpr> )
|
||||
#command CONTINUE => __dbContinue()
|
||||
#ifdef HB_COMPAT_C53
|
||||
#command SEEK <exp> [<soft: SOFTSEEK>] [<last: LAST>] => ;
|
||||
dbSeek( <exp>, if( <.soft.>, .T., NIL ), if( <.last.>, .T., NIL ) )
|
||||
#else
|
||||
#command SEEK <exp> [<soft: SOFTSEEK>] => ;
|
||||
dbSeek( <exp>, if( <.soft.>, .T., NIL ) )
|
||||
#endif
|
||||
#command LOCATE [FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] => ;
|
||||
__dbLocate( <{for}>, <{while}>, <next>, <rec>, <.rest.> )
|
||||
|
||||
#command SET RELATION TO => dbClearRelation()
|
||||
#command SET RELATION [<add:ADDITIVE>] ;
|
||||
[TO <exp1> INTO <(alias1)> [<scp1:SCOPED>];
|
||||
[, [TO] <expN> INTO <(aliasN)> [<scpN:SCOPED>]]] => ;
|
||||
if ( !<.add.> ) ; dbClearRelation() ; end ;
|
||||
; dbSetRelation( <(alias1)>, <{exp1}>, <"exp1">, <.scp1.> ) ;
|
||||
[ ; dbSetRelation( <(aliasN)>, <{expN}>, <"expN">, <.scpN.> )]
|
||||
|
||||
#command SET FILTER TO => dbClearFilter(NIL)
|
||||
#command SET FILTER TO <exp> => dbSetFilter( <{exp}>, <"exp"> )
|
||||
#command SET FILTER TO <x:&> => if ( Empty(<(x)>) ) ; dbClearFilter() ;;
|
||||
else ; dbSetFilter( <{x}>, <(x)> ) ; end
|
||||
#command REPLACE [ <f1> WITH <x1> [, <fN> WITH <xN>] ] ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] => ;
|
||||
DBEval( {|| _FIELD-><f1> := <x1> [, _FIELD-><fN> := <xN>]}, ;
|
||||
<{for}>, <{while}>, <next>, <rec>, <.rest.> )
|
||||
#command REPLACE <f1> WITH <v1> [, <fN> WITH <vN> ] => ;
|
||||
_FIELD-><f1> := <v1> [; _FIELD-><fN> := <vN>]
|
||||
|
||||
#command DELETE [FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] => ;
|
||||
DBEval( {|| dbDelete()}, <{for}>, <{while}>, <next>, <rec>, <.rest.> )
|
||||
#command DELETE => dbDelete()
|
||||
|
||||
#command RECALL [FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] => ;
|
||||
DBEval( {|| dbRecall()}, <{for}>, <{while}>, <next>, <rec>, <.rest.> )
|
||||
#command RECALL => dbRecall()
|
||||
|
||||
#command CREATE <(db)> [FROM <(src)>] [VIA <rdd>] [ALIAS <a>] ;
|
||||
[<new: NEW>] [CODEPAGE <cp>] => ;
|
||||
__dbCreate( <(db)>, <(src)>, <rdd>, <.new.>, <(a)> [, <cp>] )
|
||||
|
||||
#command COPY [STRUCTURE] [EXTENDED] [TO <(f)>] => __dbCopyXStruct( <(f)> )
|
||||
#command COPY [STRUCTURE] [TO <(f)>] [FIELDS <fields,...>] => ;
|
||||
__dbCopyStruct( <(f)>, { <(fields)> } )
|
||||
|
||||
#command COPY [TO <(f)>] [FIELDS <fields,...>] ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] ;
|
||||
[DELIMITED [WITH <*delim*>]] => ;
|
||||
__dbDelim( .T., <(f)>, <(delim)>, { <(fields)> }, ;
|
||||
<{for}>, <{while}>, <next>, <rec>, <.rest.> )
|
||||
|
||||
#command COPY [TO <(f)>] [SDF] [FIELDS <fields,...>] ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] => ;
|
||||
__dbSDF( .T., <(f)>, { <(fields)> }, ;
|
||||
<{for}>, <{while}>, <next>, <rec>, <.rest.> )
|
||||
|
||||
#command COPY [TO <(f)>] [FIELDS <fields,...>] ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] [VIA <rdd>] => ;
|
||||
__dbCopy( <(f)>, { <(fields)> }, ;
|
||||
<{for}>, <{while}>, <next>, <rec>, <.rest.>, <rdd> )
|
||||
|
||||
#command APPEND [FROM <(f)>] [FIELDS <fields,...>] ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] ;
|
||||
[DELIMITED [WITH <*delim*>]] => ;
|
||||
__dbDelim( .F., <(f)>, <(delim)>, { <(fields)> }, ;
|
||||
<{for}>, <{while}>, <next>, <rec>, <.rest.> )
|
||||
|
||||
#command APPEND [FROM <(f)>] [SDF] [FIELDS <fields,...>] ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] => ;
|
||||
__dbSDF( .F., <(f)>, { <(fields)> }, ;
|
||||
<{for}>, <{while}>, <next>, <rec>, <.rest.> )
|
||||
|
||||
#command APPEND [FROM <(f)>] [FIELDS <fields,...>] ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] [VIA <rdd>] => ;
|
||||
__dbApp( <(f)>, { <(fields)> }, ;
|
||||
<{for}>, <{while}>, <next>, <rec>, <.rest.>, <rdd> )
|
||||
|
||||
#command SORT [TO <(f)>] [ON <fields,...>] ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] => ;
|
||||
__dbSort( <(f)>, { <(fields)> }, ;
|
||||
<{for}>, <{while}>, <next>, <rec>, <.rest.> )
|
||||
|
||||
#command TOTAL [TO <(f)>] [ON <key>] [FIELDS <fields,...>] ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] => ;
|
||||
__dbTotal( <(f)>, <{key}>, { <(fields)> }, ;
|
||||
<{for}>, <{while}>, <next>, <rec>, <.rest.> )
|
||||
|
||||
#command UPDATE [FROM <(alias)>] [ON <key>] [<rand:RANDOM>] ;
|
||||
[REPLACE <f1> WITH <x1> [, <fN> WITH <xN>]] => ;
|
||||
__dbUpdate( <(alias)>, <{key}>, <.rand.>, ;
|
||||
{|| _FIELD-><f1> := <x1> [, _FIELD-><fN> := <xN>]} )
|
||||
|
||||
#command JOIN [WITH <(alias)>] [TO <f>] [FIELDS <fields,...>] [FOR <for>] => ;
|
||||
__dbJoin( <(alias)>, <(f)>, { <(fields)> }, ;
|
||||
if(EMPTY(#<for>), { || .T. }, <{for}> ) )
|
||||
|
||||
#command COUNT [TO <v>] ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] => ;
|
||||
<v> := 0 ; DBEval( {|| <v> := <v> + 1}, ;
|
||||
<{for}>, <{while}>, <next>, <rec>, <.rest.> )
|
||||
|
||||
#command SUM [ <x1> [, <xN>] TO <v1> [, <vN>] ] ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] => ;
|
||||
<v1> := [ <vN> := ] 0 ;;
|
||||
DBEval( {|| <v1> := <v1> + <x1> [, <vN> := <vN> + <xN> ]}, ;
|
||||
<{for}>, <{while}>, <next>, <rec>, <.rest.> )
|
||||
|
||||
#command AVERAGE [ <x1> [, <xN>] TO <v1> [, <vN>] ] ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] => ;
|
||||
M->__Avg := <v1> := [ <vN> := ] 0 ;;
|
||||
DBEval( {|| M->__Avg := M->__Avg + 1, ;
|
||||
<v1> := <v1> + <x1> [, <vN> := <vN> + <xN>] }, ;
|
||||
<{for}>, <{while}>, <next>, <rec>, <.rest.> ) ;;
|
||||
<v1> := <v1> / M->__Avg [ ; <vN> := <vN> / M->__Avg ]
|
||||
|
||||
#command LIST [<v,...>] [<off:OFF>] [<prn:TO PRINTER>] [TO FILE <(f)>] ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] => ;
|
||||
__dbList( <.off.>, { <{v}> }, .t., ;
|
||||
<{for}>, <{while}>, <next>, <rec>, <.rest.>, <.prn.>, <(f)> )
|
||||
|
||||
#command DISPLAY [<v,...>] [<off:OFF>] [<prn:TO PRINTER>] [TO FILE <(f)>] ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [<all:ALL>] => ;
|
||||
__dbList( <.off.>, { <{v}> }, <.all.>, ;
|
||||
<{for}>, <{while}>, <next>, <rec>, <.rest.>, <.prn.>, <(f)> )
|
||||
|
||||
#command REPORT FORM <frm> [HEADING <head>] [<plain:PLAIN>] [<noej:NOEJECT>] ;
|
||||
[<sum:SUMMARY>] [<nocon:NOCONSOLE>] ;
|
||||
[<prn:TO PRINTER>] [TO FILE <(f)>] ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] => ;
|
||||
__ReportForm( <(frm)>, <.prn.>, <(f)>, <.nocon.>, ;
|
||||
<{for}>, <{while}>, <next>, <rec>, <.rest.>, ;
|
||||
<.plain.>, <head>, <.noej.>, <.sum.> )
|
||||
|
||||
#command LABEL FORM <lbl> [<smp:SAMPLE>] [<nocon:NOCONSOLE>] ;
|
||||
[<prn:TO PRINTER>] [TO FILE <(f)>] ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [ALL] => ;
|
||||
__LabelForm( <(lbl)>, <.prn.>, <(f)>, <.nocon.>, ;
|
||||
<{for}>, <{while}>, <next>, <rec>, <.rest.>, <.smp.> )
|
||||
|
||||
#command DELETE TAG <(tag1)> [IN <(bag1)>] [, <(tagN)> [IN <(bagN)>]] => ;
|
||||
ordDestroy( <(tag1)>, <(bag1)> )[ ; ordDestroy( <(tagN)>, <(bagN)> ) ]
|
||||
|
||||
#command INDEX ON <key> [TAG <(tag)>] TO <(bag)> ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [<all:ALL>] ;
|
||||
[EVAL <eval>] [EVERY <every>] [<unique: UNIQUE>] ;
|
||||
[<ascend: ASCENDING>] [<descend: DESCENDING>] ;
|
||||
[<add: ADDITIVE>] [<cur: USECURRENT>] [<cust: CUSTOM>] ;
|
||||
[<noopt: NOOPTIMIZE>] [<mem: MEMORY, TEMPORARY>] ;
|
||||
[<filter: USEFILTER>] [<ex: EXCLUSIVE>] => ;
|
||||
ordCondSet( <"for">, <{for}>, [<.all.>], <{while}>, ;
|
||||
<{eval}>, <every>, RECNO(), <next>, <rec>, ;
|
||||
[<.rest.>], [<.descend.>],, ;
|
||||
[<.add.>], [<.cur.>], [<.cust.>], [<.noopt.>], ;
|
||||
<"while">, [<.mem.>], [<.filter.>], [<.ex.>] ) ;;
|
||||
ordCreate( <(bag)>, <(tag)>, <"key">, <{key}>, [<.unique.>] )
|
||||
|
||||
#command INDEX ON <key> TAG <(tag)> [TO <(bag)>] ;
|
||||
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
|
||||
[RECORD <rec>] [<rest:REST>] [<all:ALL>] ;
|
||||
[EVAL <eval>] [EVERY <every>] [<unique: UNIQUE>] ;
|
||||
[<ascend: ASCENDING>] [<descend: DESCENDING>] ;
|
||||
[<add: ADDITIVE>] [<cur: USECURRENT>] [<cust: CUSTOM>] ;
|
||||
[<noopt: NOOPTIMIZE>] [<mem: MEMORY, TEMPORARY>] ;
|
||||
[<filter: USEFILTER>] [<ex: EXCLUSIVE>] => ;
|
||||
ordCondSet( <"for">, <{for}>, [<.all.>], <{while}>, ;
|
||||
<{eval}>, <every>, RECNO(), <next>, <rec>, ;
|
||||
[<.rest.>], [<.descend.>],, ;
|
||||
[<.add.>], [<.cur.>], [<.cust.>], [<.noopt.>], ;
|
||||
<"while">, [<.mem.>], [<.filter.>], [<.ex.>] ) ;;
|
||||
ordCreate( <(bag)>, <(tag)>, <"key">, <{key}>, [<.unique.>] )
|
||||
|
||||
#command INDEX ON <key> TO <(file)> [<u: UNIQUE>] => ;
|
||||
dbCreateIndex( <(file)>, <"key">, <{key}>, if( <.u.>, .t., NIL ) )
|
||||
|
||||
#command REINDEX [EVAL <eval>] [EVERY <every>] [<lNoOpt: NOOPTIMIZE>] => ;
|
||||
ordCondSet(,,,, <{eval}>, <every>,,,,,,,,,, <.lNoOpt.>) ;;
|
||||
ordListRebuild()
|
||||
#command REINDEX => ordListRebuild()
|
||||
|
||||
|
||||
#command READ => ReadModal(GetList) ; GetList := {}
|
||||
#command READ SAVE => ReadModal(GetList)
|
||||
#command CLEAR GETS => ReadKill(.T.) ; GetList := {}
|
||||
|
||||
#xcommand @ [<exp,...>] COLOUR [<nextexp,...>] => @ [ <exp>] COLOR [ <nextexp>]
|
||||
|
||||
#command @ <row>, <col> SAY <say> [<sayexp,...>] GET <get> [<getexp,...>] => ;
|
||||
@ <row>, <col> SAY <say> [ <sayexp>] ;;
|
||||
@ Row(), Col() + 1 GET <get> [ <getexp>]
|
||||
|
||||
#command @ <row>, <col> GET <v> [<exp,...>] RANGE <l>, <h> [<nextexp,...>] => ;
|
||||
@ <row>, <col> GET <v> [ <exp>] ;
|
||||
VALID { |_1| RangeCheck( _1, , <l>, <h> ) } [ <nextexp>]
|
||||
|
||||
#command @ <row>, <col> GET <v> [<exp,...>] COLOR <clr> [<nextexp,...>] => ;
|
||||
@ <row>, <col> GET <v> [ <exp>] SEND colorDisp(<clr>) [ <nextexp>]
|
||||
|
||||
#ifdef HB_COMPAT_C53
|
||||
|
||||
#command READ [MENU <oMenu>] ;
|
||||
[MSG AT <row>, <left>, <right> [MSG COLOR <color>]] => ;
|
||||
ReadModal( GetList, NIL, <oMenu>, <row>, <left>, <right>, <color> ) ;;
|
||||
GetList := {}
|
||||
|
||||
#command READ SAVE [MENU <oMenu>] ;
|
||||
[MSG AT <row>, <left>, <right> [MSG COLOR <color>]] => ;
|
||||
ReadModal( GetList, NIL, <oMenu>, <row>, <left>, <right>, <color> )
|
||||
|
||||
#command @ <row>, <col> GET <v> [PICTURE <pic>] ;
|
||||
[VALID <valid>] [WHEN <when>] [SEND <snd>] ;
|
||||
[CAPTION <cap>] [MESSAGE <msg>] => ;
|
||||
SetPos( <row>, <col> ) ;;
|
||||
AAdd( GetList, _GET_( <v>, <"v">, <pic>, <{valid}>, <{when}> ) ) ;;
|
||||
[ ATail(GetList):Caption := <cap> ;;
|
||||
ATail(GetList):CapRow := ATail(Getlist):row ;;
|
||||
ATail(GetList):CapCol := ATail(Getlist):col - __CapLength(<cap>) - 1 ;] ;
|
||||
[ ATail(GetList):message := <msg> ;] [ ATail(GetList):<snd> ;] ;
|
||||
ATail(GetList):Display()
|
||||
|
||||
#command @ <row>, <col> GET <v> CHECKBOX [VALID <valid>] [WHEN <when>] ;
|
||||
[CAPTION <cap>] [MESSAGE <msg>] [COLOR <clr>] ;
|
||||
[FOCUS <fb>] [STATE <sb>] [STYLE <stl>] ;
|
||||
[SEND <snd>] [GUISEND <gsnd>] [BITMAPS <bmaps>] => ;
|
||||
SetPos( <row>, <col> ) ;;
|
||||
AAdd( GetList, _GET_( <v>, <(v)>, NIL, <{valid}>, <{when}> ) ) ;;
|
||||
ATail(GetList):Control := _CheckBox_( <v>, <cap>, ;
|
||||
<msg>, <clr>, <{fb}>, <{sb}>, <stl>, <bmaps> ) ;;
|
||||
ATail(GetList):reader := { | a, b, c, d | GuiReader( a, b, c, d ) } ;;
|
||||
[ ATail(GetList):<snd> ;] [ ATail(GetList):Control:<gsnd> ;] ;
|
||||
ATail(GetList):Control:Display()
|
||||
|
||||
#command @ <top>, <left>, <bottom>, <right> GET <v> LISTBOX <items> ;
|
||||
[VALID <valid>] [WHEN <when>] ;
|
||||
[CAPTION <cap>] [MESSAGE <msg>] [COLOR <clr>] ;
|
||||
[FOCUS <fb>] [STATE <sb>] [<dd:DROPDOWN>] [<sbar:SCROLLBAR>] ;
|
||||
[SEND <snd>] [GUISEND <gsnd>] [BITMAP <bmap>] => ;
|
||||
SetPos( <top>, <left> ) ;;
|
||||
AAdd( GetList, _GET_( <v>, <(v)>, NIL, <{valid}>, <{when}> ) ) ;;
|
||||
ATail(GetList):Control := _ListBox_( ATail(Getlist):row, ;
|
||||
ATail(Getlist):col, <bottom>, <right>, <v>, <items>, <cap>, ;
|
||||
<msg>, <clr>, <{fb}>, <{sb}>, <.dd.>, <.sbar.>, <bmap> ) ;;
|
||||
ATail(GetList):reader := { | a, b, c, d | GuiReader( a, b, c, d ) } ;;
|
||||
[ ATail(GetList):<snd> ;] [ ATail(GetList):Control:<gsnd> ;] ;
|
||||
ATail(GetList):Control:Display()
|
||||
|
||||
#command @ <row>, <col> GET <v> PUSHBUTTON ;
|
||||
[VALID <valid>] [WHEN <when>] ;
|
||||
[CAPTION <cap>] [MESSAGE <msg>] [COLOR <clr>] ;
|
||||
[FOCUS <fb>] [STATE <sb>] [STYLE <stl>] ;
|
||||
[SEND <snd>] [GUISEND <gsnd>] [BITMAP <bmap>] ;
|
||||
[SIZE X <sX> Y <sY>] [CAPOFF X <cX> Y <cY> ] ;
|
||||
[BMPOFF X <bX> Y <bY>] => ;
|
||||
SetPos( <row>, <col> ) ;;
|
||||
AAdd( GetList, _GET_( <v>, <(v)>, NIL, <{valid}>, <{when}> ) ) ;;
|
||||
ATail(GetList):Control := _PushButt_( <cap>, <msg>, <clr>, <{fb}>,;
|
||||
<{sb}>, <stl>, <sX>, <sY>, <cX>, <cY>, <bmap>, <bX>, <bY> ) ;;
|
||||
ATail(GetList):reader := { | a, b, c, d | GuiReader( a, b, c, d ) } ;;
|
||||
[ ATail(GetList):<snd> ;] [ ATail(GetList):Control:<gsnd> ;] ;
|
||||
ATail(GetList):Control:Display()
|
||||
|
||||
#command @ <top>, <left>, <bottom>, <right> GET <v> RADIOGROUP <buttons> ;
|
||||
[VALID <valid>] [WHEN <when>] ;
|
||||
[CAPTION <cap>] [MESSAGE <msg>] [COLOR <clr>] ;
|
||||
[FOCUS <fb>] [STYLE <stl>] ;
|
||||
[SEND <snd>] [GUISEND <gsnd>] => ;
|
||||
SetPos( <top>, <left> ) ;;
|
||||
AAdd( GetList, _GET_( <v>, <(v)>, NIL, <{valid}>, <{when}> ) ) ;;
|
||||
ATail(GetList):Control := _RadioGrp_( ATail(Getlist):row, ;
|
||||
ATail(Getlist):col, <bottom>, <right>, <v>, <buttons>, <cap>,;
|
||||
<msg>, <clr>, <{fb}>, <stl> ) ;;
|
||||
ATail(GetList):reader := { | a, b, c, d | GuiReader( a, b, c, d ) } ;;
|
||||
[ ATail(GetList):<snd> ;] [ ATail(GetList):Control:<gsnd> ;] ;
|
||||
ATail(GetList):Control:Display()
|
||||
|
||||
#command @ <top>, <left>, <bottom>, <right> GET <v> TBROWSE <oBrowse> ;
|
||||
[VALID <valid>] [WHEN <when>] ;
|
||||
[MESSAGE <msg>] [SEND <snd>] [GUISEND <gsnd>] => ;
|
||||
SetPos( <top>, <left> ) ;;
|
||||
AAdd( GetList, _GET_( <v>, <(v)>, NIL, <{valid}>, <{when}> ) ) ;;
|
||||
<oBrowse>:ntop := ATail(Getlist):row ;;
|
||||
<oBrowse>:nleft := ATail(Getlist):col ;;
|
||||
<oBrowse>:nbottom := <bottom> ; <oBrowse>:nright := <right> ;;
|
||||
<oBrowse>:Configure() ; ATail(GetList):Control := <oBrowse> ;;
|
||||
ATail(GetList):reader := { | a, b, c, d | TBReader( a, b, c, d ) } ;
|
||||
[ ; ATail(GetList):Control:Message := <msg>] ;
|
||||
[ ; ATail(GetList):<snd>] [ ; ATail(GetList):Control:<gsnd>]
|
||||
|
||||
#command @ <top>, <left>, <bottom>, <right> GET <v> TBROWSE <oBrowse> ;
|
||||
ALIAS <a> [VALID <valid>] [WHEN <when>] ;
|
||||
[MESSAGE <msg>] [SEND <snd>] [GUISEND <gsnd>] => ;
|
||||
SetPos( <top>, <left> ) ;;
|
||||
AAdd( GetList, _GET_( <v>, <(v)>, NIL, <{valid}>, <{when}> ) ) ;;
|
||||
<oBrowse>:ntop := ATail(Getlist):row ;;
|
||||
<oBrowse>:nleft := ATail(Getlist):col ;;
|
||||
<oBrowse>:nbottom := <bottom> ; <oBrowse>:nright := <right> ;;
|
||||
<oBrowse>:Configure() ; ATail(GetList):Control := <oBrowse> ;;
|
||||
ATail(GetList):reader := { | a, b, c, d | <a>->( TBReader( a, b, c, d ) ) } ;
|
||||
[ ; ATail(GetList):Control:Message := <msg>] ;
|
||||
[ ; ATail(GetList):<snd>] [ ; ATail(GetList):Control:<gsnd>]
|
||||
|
||||
#else
|
||||
|
||||
#command @ <row>, <col> GET <v> [PICTURE <pic>] ;
|
||||
[VALID <valid>] [WHEN <when>] [SEND <snd>] => ;
|
||||
SetPos( <row>, <col> ) ; AAdd( GetList, ;
|
||||
_GET_( <v>, <"v">, <pic>, <{valid}>, <{when}> ):Display() ) ;
|
||||
[; ATail(GetList):<snd>]
|
||||
|
||||
#endif /* HB_COMPAT_C53 */
|
||||
|
||||
#endif /* HB_STD_CH_ */
|
||||
|
||||
@@ -60,10 +60,17 @@
|
||||
* hb_dateStrPut()
|
||||
* hb_dateStrGet()
|
||||
*
|
||||
* Copyright 1999 Jose Lalin <dezac@corevia.com>
|
||||
* hb_dateDOW()
|
||||
*
|
||||
* See doc/license.txt for licensing terms.
|
||||
*
|
||||
*/
|
||||
|
||||
#define HB_OS_WIN_32_USED
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbdate.h"
|
||||
|
||||
@@ -237,3 +244,51 @@ HB_EXPORT int hb_dateDOW( int iYear, int iMonth, int iDay )
|
||||
return ( iDay + 26 * iMonth / 10 +
|
||||
iYear + iYear / 4 - iYear / 100 + iYear / 400 + 6 ) % 7 + 1;
|
||||
}
|
||||
|
||||
HB_EXPORT void hb_dateToday( int * piYear, int * piMonth, int * piDay )
|
||||
{
|
||||
#if defined(HB_OS_WIN_32)
|
||||
|
||||
SYSTEMTIME st;
|
||||
GetLocalTime( &st );
|
||||
|
||||
*piYear = st.wYear;
|
||||
*piMonth = st.wMonth;
|
||||
*piDay = st.wDay;
|
||||
|
||||
#else
|
||||
|
||||
time_t t;
|
||||
struct tm * oTime;
|
||||
|
||||
time( &t );
|
||||
oTime = localtime( &t );
|
||||
|
||||
*piYear = oTime->tm_year + 1900;
|
||||
*piMonth = oTime->tm_mon + 1;
|
||||
*piDay = oTime->tm_mday;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/* NOTE: The passed buffer must be at least 9 chars long */
|
||||
|
||||
HB_EXPORT void hb_dateTimeStr( char * pszTime )
|
||||
{
|
||||
#if defined(HB_OS_WIN_32)
|
||||
{
|
||||
SYSTEMTIME st;
|
||||
GetLocalTime( &st );
|
||||
sprintf( pszTime, "%02d:%02d:%02d", st.wHour, st.wMinute, st.wSecond );
|
||||
}
|
||||
#else
|
||||
{
|
||||
time_t t;
|
||||
struct tm * oTime;
|
||||
|
||||
time( &t );
|
||||
oTime = localtime( &t );
|
||||
sprintf( pszTime, "%02d:%02d:%02d", oTime->tm_hour, oTime->tm_min, oTime->tm_sec );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ extern void hb_fhnd_ForceLink( void );
|
||||
/*
|
||||
* Function that adds zero or more paths to a list of pathnames to search
|
||||
*/
|
||||
void hb_fsAddSearchPath( char * szPath, HB_PATHNAMES ** pSearchList )
|
||||
void hb_fsAddSearchPath( const char * szPath, HB_PATHNAMES ** pSearchList )
|
||||
{
|
||||
char * pPath;
|
||||
char * pDelim;
|
||||
|
||||
@@ -667,7 +667,7 @@ HB_EXPORT HB_LONG hb_strValInt( const char * szText, int * iOverflow )
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_strValInt(%s)", szText));
|
||||
|
||||
if ( hb_str2number( FALSE, szText, strlen( szText ), &lVal, &dVal, NULL, NULL ) )
|
||||
if ( hb_str2number( TRUE, szText, strlen( szText ), &lVal, &dVal, NULL, NULL ) )
|
||||
{
|
||||
*iOverflow = 1;
|
||||
return 0;
|
||||
@@ -853,53 +853,55 @@ HB_EXPORT char * hb_strncpyTrim( char * pDest, const char * pSource, ULONG ulLen
|
||||
|
||||
char * hb_strRemEscSeq( char *str, ULONG *pLen )
|
||||
{
|
||||
char *ptr = str;
|
||||
|
||||
while( *ptr )
|
||||
{
|
||||
if( *ptr == '\\' )
|
||||
{
|
||||
switch( *(ptr+1) )
|
||||
char *ptr, *dst, ch;
|
||||
ULONG ul = *pLen, ulStripped = 0;
|
||||
|
||||
ptr = dst = str;
|
||||
while( ul )
|
||||
{
|
||||
if( *ptr == '\\' )
|
||||
break;
|
||||
++ptr; ++dst;
|
||||
--ul;
|
||||
}
|
||||
|
||||
while( ul-- )
|
||||
{
|
||||
ch = *ptr++;
|
||||
if( ch == '\\' )
|
||||
{
|
||||
case '\\':
|
||||
{
|
||||
memmove( ptr, ptr+1, *pLen - (ptr - str) );
|
||||
(*pLen)--;
|
||||
break;
|
||||
}
|
||||
case 'r':
|
||||
{
|
||||
memmove( ptr, ptr+1, *pLen - (ptr - str) );
|
||||
*ptr = '\r';
|
||||
(*pLen)--;
|
||||
break;
|
||||
}
|
||||
case 'n':
|
||||
{
|
||||
memmove( ptr, ptr+1, *pLen - (ptr - str) );
|
||||
*ptr = '\n';
|
||||
(*pLen)--;
|
||||
break;
|
||||
}
|
||||
case 't':
|
||||
{
|
||||
memmove( ptr, ptr+1, *pLen - (ptr - str) );
|
||||
*ptr = '\t';
|
||||
(*pLen)--;
|
||||
break;
|
||||
}
|
||||
case 'b':
|
||||
{
|
||||
memmove( ptr, ptr+1, *pLen - (ptr - str) );
|
||||
*ptr = '\b';
|
||||
(*pLen)--;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
++ulStripped;
|
||||
ch = *ptr++;
|
||||
switch( ch )
|
||||
{
|
||||
case 'r':
|
||||
ch = '\r';
|
||||
break;
|
||||
case 'n':
|
||||
ch = '\n';
|
||||
break;
|
||||
case 't':
|
||||
ch = '\t';
|
||||
break;
|
||||
case 'b':
|
||||
ch = '\b';
|
||||
break;
|
||||
case 'q':
|
||||
ch = '"';
|
||||
break;
|
||||
case '\\':
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
return str;
|
||||
*dst++ = ch;
|
||||
}
|
||||
|
||||
if( ulStripped )
|
||||
{
|
||||
*dst = '\0';
|
||||
*pLen -= ulStripped;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ C_SOURCES=\
|
||||
hbstrong.c \
|
||||
hbusage.c \
|
||||
hbident.c \
|
||||
ppcomp.c \
|
||||
expropta.c \
|
||||
exproptb.c \
|
||||
exproptc.c \
|
||||
|
||||
@@ -49,8 +49,6 @@
|
||||
|
||||
#include "hbcomp.h"
|
||||
|
||||
extern int hb_pp_ParseDefine( char * );
|
||||
|
||||
/* TODO: Add support for this compiler switches
|
||||
-r -t || hb_getenv( "TMP" )
|
||||
*/
|
||||
@@ -908,7 +906,7 @@ static void hb_compChkDefineSwitch( char *pszSwitch )
|
||||
{
|
||||
if( pszSwitch[1] == 'd' || pszSwitch[1] == 'D' )
|
||||
{
|
||||
char *szDefText = hb_strdup( pszSwitch + 2 ), *pAssign, *sDefLine;
|
||||
char *szDefText = hb_strdup( pszSwitch + 2 ), *pAssign, *szDefLine;
|
||||
unsigned int i = 0;
|
||||
|
||||
while( i < strlen( szDefText ) && !HB_ISOPTSEP( szDefText[i] ) )
|
||||
@@ -926,10 +924,10 @@ static void hb_compChkDefineSwitch( char *pszSwitch )
|
||||
szDefText[pAssign - szDefText] = '\0';
|
||||
|
||||
/* hb_pp_AddDefine( szDefText, pAssign + 1 ); */
|
||||
sDefLine = ( char * ) hb_xgrab( strlen( szDefText ) + 1 + strlen( pAssign + 1 ) + 1 );
|
||||
sprintf( sDefLine, "%s %s", szDefText, pAssign + 1 );
|
||||
hb_pp_ParseDefine( sDefLine );
|
||||
hb_xfree( sDefLine );
|
||||
szDefLine = ( char * ) hb_xgrab( strlen( szDefText ) + strlen( pAssign + 1 ) + 10 );
|
||||
sprintf( szDefLine, "#define %s %s", szDefText, pAssign + 1 );
|
||||
hb_pp_ParseDirective( szDefLine );
|
||||
hb_xfree( szDefLine );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ static void hb_compGenOutput( int );
|
||||
static void hb_compOutputFile( void );
|
||||
static void hb_compPpoFile( void );
|
||||
static void hb_compCompileEnd( void );
|
||||
static int hb_compCompile( char * szPrg, BOOL bSingleFile );
|
||||
|
||||
|
||||
int hb_compLocalGetPos( char * szVarName ); /* returns the order + 1 of a local variable */
|
||||
@@ -86,7 +87,7 @@ static void hb_compGenVariablePCode( BYTE , char * ); /* generates the pcode
|
||||
static PFUNCTION hb_compFunctionNew( char *, HB_SYMBOLSCOPE ); /* creates and initialises the _FUNC structure */
|
||||
static PINLINE hb_compInlineNew( char * ); /* creates and initialises the _INLINE structure */
|
||||
static void hb_compCheckDuplVars( PVAR pVars, char * szVarName ); /*checks for duplicate variables definitions */
|
||||
static int hb_compProcessRSPFile( char *, int, char * argv[] ); /* process response file */
|
||||
static int hb_compProcessRSPFile( char * ); /* process response file */
|
||||
|
||||
static void hb_compOptimizeJumps( void );
|
||||
static void hb_compOptimizeFrames( PFUNCTION pFunc );
|
||||
@@ -163,6 +164,8 @@ ULONG hb_comp_Supported;
|
||||
|
||||
FILE * hb_comp_errFile = NULL;
|
||||
|
||||
int hb_comp_iHidden; /* Hide Strings */
|
||||
|
||||
|
||||
/* EXTERNAL statement can be placed into any place in a function - this flag is
|
||||
* used to suppress error report generation
|
||||
@@ -243,7 +246,7 @@ int main( int argc, char * argv[] )
|
||||
hb_compChkPaths();
|
||||
|
||||
/* Set standard rules */
|
||||
hb_pp_SetRules( hb_compInclude, hb_comp_bQuiet );
|
||||
hb_pp_SetRules( hb_comp_bQuiet, argc, argv );
|
||||
|
||||
/* Prepare the table of identifiers */
|
||||
hb_compIdentifierOpen();
|
||||
@@ -276,9 +279,9 @@ int main( int argc, char * argv[] )
|
||||
}
|
||||
|
||||
if( argv[ i ][ 0 ] == '@' )
|
||||
iStatus = hb_compProcessRSPFile( argv[ i ] + 1, argc, argv );
|
||||
iStatus = hb_compProcessRSPFile( argv[ i ] + 1 );
|
||||
else
|
||||
iStatus = hb_compCompile( argv[ i ], argc, argv, TRUE );
|
||||
iStatus = hb_compCompile( argv[ i ], TRUE );
|
||||
|
||||
if( iStatus != EXIT_SUCCESS )
|
||||
break;
|
||||
@@ -342,7 +345,7 @@ void hb_compMainExit( void )
|
||||
hb_xexit();
|
||||
}
|
||||
|
||||
static int hb_compProcessRSPFile( char * szRspName, int argc, char * argv[] )
|
||||
static int hb_compProcessRSPFile( char * szRspName )
|
||||
{
|
||||
char szFile[ _POSIX_PATH_MAX + 1 ];
|
||||
int iStatus = EXIT_SUCCESS;
|
||||
@@ -413,7 +416,7 @@ static int hb_compProcessRSPFile( char * szRspName, int argc, char * argv[] )
|
||||
hb_comp_bAutoOpen = bAutoOpen;
|
||||
|
||||
hb_fsFNameMerge( szFile, pFileName );
|
||||
hb_compCompile( szFile, argc, argv, FALSE );
|
||||
hb_compCompile( szFile, FALSE );
|
||||
}
|
||||
|
||||
hb_xfree( pFileName );
|
||||
@@ -4622,7 +4625,7 @@ static void hb_compPpoFile( void )
|
||||
else
|
||||
*/
|
||||
}
|
||||
hb_comp_pFilePpo->szExtension = ".ppo";
|
||||
hb_comp_pFilePpo->szExtension = ".ppo";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4648,7 +4651,7 @@ static void hb_compOutputFile( void )
|
||||
}
|
||||
}
|
||||
|
||||
int hb_compCompile( char * szPrg, int argc, char * argv[], BOOL bSingleFile )
|
||||
int hb_compCompile( char * szPrg, BOOL bSingleFile )
|
||||
{
|
||||
int iStatus = EXIT_SUCCESS;
|
||||
|
||||
@@ -4684,7 +4687,7 @@ int hb_compCompile( char * szPrg, int argc, char * argv[], BOOL bSingleFile )
|
||||
if( iStatus == EXIT_SUCCESS )
|
||||
{
|
||||
/* Add /D command line or envvar defines */
|
||||
hb_compChkDefines( argc, argv );
|
||||
/* hb_compChkDefines( argc, argv ); */
|
||||
|
||||
/* Initialize support variables */
|
||||
hb_compInitVars();
|
||||
@@ -4721,12 +4724,14 @@ int hb_compCompile( char * szPrg, int argc, char * argv[], BOOL bSingleFile )
|
||||
|
||||
yyparse();
|
||||
|
||||
if( hb_comp_bPPO && hb_comp_yyppo )
|
||||
if( hb_comp_yyppo )
|
||||
{
|
||||
fclose( hb_comp_yyppo );
|
||||
hb_comp_yyppo = NULL;
|
||||
if( hb_comp_pFilePpo )
|
||||
hb_xfree( hb_comp_pFilePpo );
|
||||
}
|
||||
if( hb_comp_pFilePpo )
|
||||
{
|
||||
hb_xfree( hb_comp_pFilePpo );
|
||||
hb_comp_pFilePpo = NULL;
|
||||
}
|
||||
}
|
||||
@@ -4892,7 +4897,7 @@ static void hb_compCompileEnd( void )
|
||||
|
||||
if( hb_comp_pFileName )
|
||||
{
|
||||
if( hb_comp_pFileName != hb_comp_pMainFileName && hb_comp_pFileName )
|
||||
if( hb_comp_pFileName != hb_comp_pMainFileName && hb_comp_pMainFileName )
|
||||
{
|
||||
/* currently compiled file was autoopened - close also
|
||||
* the main module
|
||||
@@ -4904,12 +4909,14 @@ static void hb_compCompileEnd( void )
|
||||
hb_comp_pFileName = NULL;
|
||||
}
|
||||
|
||||
if( hb_comp_bPPO && hb_comp_yyppo )
|
||||
if( hb_comp_yyppo )
|
||||
{
|
||||
fclose( hb_comp_yyppo );
|
||||
hb_comp_yyppo = NULL;
|
||||
if( hb_comp_pFilePpo )
|
||||
hb_xfree( hb_comp_pFilePpo );
|
||||
}
|
||||
if( hb_comp_pFilePpo )
|
||||
{
|
||||
hb_xfree( hb_comp_pFilePpo );
|
||||
hb_comp_pFilePpo = NULL;
|
||||
}
|
||||
|
||||
@@ -5137,12 +5144,14 @@ int hb_compAutoOpen( char * szPrg, BOOL * pbSkipGen, BOOL bSingleFile )
|
||||
|
||||
yyparse();
|
||||
|
||||
if( hb_comp_bPPO && hb_comp_yyppo )
|
||||
if( hb_comp_yyppo )
|
||||
{
|
||||
fclose( hb_comp_yyppo );
|
||||
hb_comp_yyppo = NULL;
|
||||
if( hb_comp_pFilePpo )
|
||||
hb_xfree( hb_comp_pFilePpo );
|
||||
}
|
||||
if( hb_comp_pFilePpo )
|
||||
{
|
||||
hb_xfree( hb_comp_pFilePpo );
|
||||
hb_comp_pFilePpo = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ FalseValue "."[f|n]"."
|
||||
|
||||
Separator {SpaceTab}
|
||||
|
||||
%x STRING1 STRING2 STRING3 STRING4START STRING4 STRING5
|
||||
%x STRINGEXT STRING1 STRING2 STRING3 STRING4START STRING4 STRING5
|
||||
%x NEXT_ BREAK_ CASE_ DO_ DOIDENT_ WHILE_ WITH_ END_ FIELD_
|
||||
%x FOR_ FOREACH_ FUNCTION_ IIF_ IF_ IN_ INIT_
|
||||
%x RETURN_ RECOVER_
|
||||
@@ -146,36 +146,51 @@ Separator {SpaceTab}
|
||||
|
||||
"&"(\x27|\x22|\[) { hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX, yytext, NULL ); }
|
||||
|
||||
\x27 BEGIN STRING1;
|
||||
\x22 BEGIN STRING2;
|
||||
"e"\x22 BEGIN STRINGEXT;
|
||||
\x27 BEGIN STRING1;
|
||||
\x22 BEGIN STRING2;
|
||||
|
||||
\[ {
|
||||
if( (hb_comp_iState == OPERATOR) ||
|
||||
(hb_comp_iState == LSEPARATOR) ||
|
||||
(hb_comp_iState == LARRAY) ||
|
||||
(hb_comp_iState == IF) ||
|
||||
(hb_comp_iState == ELSEIF) ||
|
||||
(hb_comp_iState == CASE) ||
|
||||
(hb_comp_iState == BREAK) ||
|
||||
(hb_comp_iState == RETURN) ||
|
||||
(hb_comp_iState == WITH) ||
|
||||
(hb_comp_iState == WHILE)
|
||||
)
|
||||
{
|
||||
if( hb_pp_NestedLiteralString )
|
||||
{
|
||||
yy_breakFlex();
|
||||
BEGIN STRING5;
|
||||
}
|
||||
else
|
||||
BEGIN STRING3;
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_comp_iState = LINDEX;
|
||||
return '[';
|
||||
}
|
||||
if( (hb_comp_iState == OPERATOR) ||
|
||||
(hb_comp_iState == LSEPARATOR) ||
|
||||
(hb_comp_iState == LARRAY) ||
|
||||
(hb_comp_iState == IF) ||
|
||||
(hb_comp_iState == ELSEIF) ||
|
||||
(hb_comp_iState == CASE) ||
|
||||
(hb_comp_iState == BREAK) ||
|
||||
(hb_comp_iState == RETURN) ||
|
||||
(hb_comp_iState == WITH) ||
|
||||
(hb_comp_iState == WHILE)
|
||||
)
|
||||
{
|
||||
if( hb_pp_NestedLiteralString )
|
||||
{
|
||||
yy_breakFlex();
|
||||
BEGIN STRING5;
|
||||
}
|
||||
else
|
||||
BEGIN STRING3;
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_comp_iState = LINDEX;
|
||||
return '[';
|
||||
}
|
||||
}
|
||||
|
||||
<STRINGEXT>[^\x22\n]*\x22 { BEGIN 0;
|
||||
yytext[--yyleng] = '\0';
|
||||
{
|
||||
ULONG len = yyleng;
|
||||
hb_strRemEscSeq( yytext, &len );
|
||||
yyleng = len;
|
||||
}
|
||||
yylval.string = hb_compIdentifierNew( yytext, TRUE );
|
||||
hb_comp_iState = LITERAL;
|
||||
|
||||
return LITERAL;
|
||||
}
|
||||
|
||||
<STRING1>[^\x27\n]*\n { BEGIN 0;
|
||||
unput( '\n' );
|
||||
yytext[--yyleng] = '\0';
|
||||
@@ -331,11 +346,13 @@ Separator {SpaceTab}
|
||||
\n {
|
||||
hb_comp_iState = LOOKUP;
|
||||
|
||||
/*
|
||||
if( ! hb_comp_bQuiet && ( hb_comp_iLine % 100 ) == 0 )
|
||||
{
|
||||
printf( "\r%i", hb_comp_iLine );
|
||||
fflush( stdout );
|
||||
}
|
||||
*/
|
||||
return '\n';
|
||||
}
|
||||
%{
|
||||
|
||||
@@ -92,7 +92,8 @@ char * hb_comp_szErrors[] =
|
||||
"Invalid date constant \'%s\'",
|
||||
"Memory buffer overflow",
|
||||
"Memory corruption detected",
|
||||
"Implicit send operator with no WITH OBJECT in sight"
|
||||
"Implicit send operator with no WITH OBJECT in sight",
|
||||
"Input buffer overflow"
|
||||
};
|
||||
|
||||
/* Table with parse warnings */
|
||||
|
||||
375
harbour/source/compiler/ppcomp.c
Normal file
375
harbour/source/compiler/ppcomp.c
Normal file
@@ -0,0 +1,375 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Compiler C source with real code generation
|
||||
*
|
||||
* Copyright 2006 Przemyslaw Czerpak < druzus /at/ priv.onet.pl >
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
|
||||
* their web site at http://www.gnu.org/).
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "hbcomp.h"
|
||||
#include <errno.h>
|
||||
|
||||
static PHB_PP_STATE s_pp_state = NULL;
|
||||
|
||||
BOOL hb_pp_NestedLiteralString = FALSE;
|
||||
BOOL hb_pp_LiteralEscSeq = FALSE;
|
||||
int hb_pp_StreamBlock = 0;
|
||||
unsigned int hb_pp_MaxTranslateCycles = 1024;
|
||||
char *hb_pp_STD_CH = NULL;
|
||||
|
||||
|
||||
|
||||
static void hb_pp_ErrorGen( char * szMsgTable[], char cPrefix, int iErrorCode,
|
||||
const char * szParam1, const char * szParam2 )
|
||||
{
|
||||
int iLine = hb_comp_iLine;
|
||||
|
||||
/* I do not know why but compiler expect line number 1 bigger then
|
||||
real line number */
|
||||
hb_comp_iLine = hb_pp_line( s_pp_state ) + 1;
|
||||
if( cPrefix == 'W' )
|
||||
hb_compGenWarning( szMsgTable, cPrefix, iErrorCode, szParam1, szParam2 );
|
||||
else
|
||||
hb_compGenError( szMsgTable, cPrefix, iErrorCode, szParam1, szParam2 );
|
||||
hb_comp_iLine = iLine;
|
||||
}
|
||||
|
||||
static FILE * hb_pp_IncludeOpen( char *szFileName, BOOL fSysFile, char * szFNameBuf )
|
||||
{
|
||||
PHB_FNAME pFileName;
|
||||
FILE *file = NULL;
|
||||
PFILE pFile;
|
||||
BOOL fPath;
|
||||
|
||||
pFileName = hb_fsFNameSplit( szFileName );
|
||||
fPath = pFileName->szPath && pFileName->szPath[ 0 ];
|
||||
errno = 0;
|
||||
if( !fSysFile )
|
||||
{
|
||||
if( !fPath && hb_comp_pFileName )
|
||||
pFileName->szPath = hb_comp_pFileName->szPath;
|
||||
|
||||
hb_fsFNameMerge( szFNameBuf, pFileName );
|
||||
|
||||
file = fopen( szFNameBuf, "r" );
|
||||
}
|
||||
|
||||
if( !file && errno != EMFILE && hb_comp_pIncludePath )
|
||||
{
|
||||
HB_PATHNAMES * pSearch = hb_comp_pIncludePath;
|
||||
|
||||
pFileName->szName = szFileName;
|
||||
pFileName->szExtension = NULL;
|
||||
while( pSearch && !file )
|
||||
{
|
||||
pFileName->szPath = pSearch->szPath;
|
||||
hb_fsFNameMerge( szFNameBuf, pFileName );
|
||||
file = fopen( szFNameBuf, "r" );
|
||||
pSearch = pSearch->pNext;
|
||||
}
|
||||
}
|
||||
hb_xfree( pFileName );
|
||||
|
||||
if( file )
|
||||
{
|
||||
pFile = ( PFILE ) hb_xgrab( sizeof( _FILE ) );
|
||||
pFile->handle = file;
|
||||
pFile->pBuffer = hb_xgrab( HB_PP_BUFF_SIZE );
|
||||
pFile->iBuffer = pFile->lenBuffer = 10;
|
||||
pFile->yyBuffer = NULL;
|
||||
pFile->szFileName = hb_strdup( szFNameBuf );
|
||||
if( hb_comp_files.pLast )
|
||||
hb_comp_files.pLast->iLine = hb_comp_iLine;
|
||||
hb_comp_iLine = 1;
|
||||
pFile->iLine = 1;
|
||||
pFile->pPrev = hb_comp_files.pLast;
|
||||
hb_comp_files.pLast = pFile;
|
||||
hb_comp_files.iFiles++;
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
static void hb_pp_IncludeClose( FILE * file )
|
||||
{
|
||||
if( hb_comp_files.iFiles > 0 && hb_comp_files.pLast &&
|
||||
file == hb_comp_files.pLast->handle )
|
||||
{
|
||||
PFILE pFile;
|
||||
fclose( hb_comp_files.pLast->handle );
|
||||
hb_xfree( hb_comp_files.pLast->pBuffer );
|
||||
hb_xfree( hb_comp_files.pLast->szFileName );
|
||||
pFile = ( PFILE ) ( ( PFILE ) hb_comp_files.pLast )->pPrev;
|
||||
#if 0
|
||||
if( hb_comp_files.pLast->yyBuffer && hb_comp_files.iFiles == 1 )
|
||||
hb_compParserStop(); /* uses hb_comp_files.pLast */
|
||||
#endif
|
||||
hb_xfree( hb_comp_files.pLast );
|
||||
hb_comp_files.pLast = pFile;
|
||||
if( hb_comp_files.pLast )
|
||||
hb_comp_iLine = hb_comp_files.pLast->iLine;
|
||||
hb_comp_files.iFiles--;
|
||||
}
|
||||
}
|
||||
|
||||
static void hb_pp_PragmaDump( char * pBuffer, ULONG ulSize, int iLine )
|
||||
{
|
||||
int iSaveLine = hb_comp_iLine;
|
||||
PINLINE pInline;
|
||||
|
||||
/* I do not know why but compiler expect line number 1 bigger then
|
||||
real line number */
|
||||
hb_comp_iLine = iLine + 1;
|
||||
|
||||
pInline = hb_compInlineAdd( NULL );
|
||||
pInline->pCode = ( BYTE * ) hb_xgrab( ulSize + 1 );
|
||||
memcpy( pInline->pCode, pBuffer, ulSize );
|
||||
pBuffer[ ulSize ] = '\0';
|
||||
pInline->lPCodeSize = ulSize;
|
||||
|
||||
hb_comp_iLine = iSaveLine;
|
||||
}
|
||||
|
||||
static BOOL hb_pp_CompilerSwitch( const char * szSwitch, int iValue )
|
||||
{
|
||||
BOOL fError = FALSE;
|
||||
int i = strlen( szSwitch );
|
||||
|
||||
if( i == 1 )
|
||||
{
|
||||
switch( szSwitch[ 0 ] )
|
||||
{
|
||||
case 'a':
|
||||
case 'A':
|
||||
hb_comp_bAutoMemvarAssume = iValue != 0;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
case 'B':
|
||||
hb_comp_bDebugInfo = iValue != 0;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
case 'L':
|
||||
hb_comp_bLineNumbers = iValue != 0;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
case 'N':
|
||||
hb_comp_bStartProc = iValue != 0;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
case 'P':
|
||||
hb_comp_bPPO = iValue != 0;
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
case 'Q':
|
||||
hb_comp_bQuiet = iValue != 0;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
case 'V':
|
||||
hb_comp_bForceMemvars = iValue != 0;
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
case 'W':
|
||||
if( iValue >= 0 && iValue <= 3 )
|
||||
hb_comp_iWarnings = iValue;
|
||||
else
|
||||
fError = TRUE;
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
case 'Z':
|
||||
hb_comp_bShortCuts = iValue != 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
fError = TRUE;
|
||||
}
|
||||
}
|
||||
else if( i == 2 )
|
||||
{
|
||||
if( szSwitch[ 1 ] - '0' == iValue && iValue >= 0 && iValue <= 3 &&
|
||||
( szSwitch[ 0 ] == 'w' || szSwitch[ 0 ] == 'W' ) &&
|
||||
( iValue >= 0 && iValue <= 3 ) )
|
||||
hb_comp_iWarnings = iValue;
|
||||
else if( hb_stricmp( szSwitch, "es" ) == 0 &&
|
||||
( iValue == HB_EXITLEVEL_DEFAULT ||
|
||||
iValue == HB_EXITLEVEL_SETEXIT ||
|
||||
iValue == HB_EXITLEVEL_DELTARGET ) )
|
||||
hb_comp_iExitLevel = iValue;
|
||||
else
|
||||
fError = TRUE;
|
||||
}
|
||||
else if( i == 3 )
|
||||
{
|
||||
if( szSwitch[ 2 ] - '0' == iValue &&
|
||||
hb_strnicmp( szSwitch, "es", 2 ) == 0 &&
|
||||
( iValue == HB_EXITLEVEL_DEFAULT ||
|
||||
iValue == HB_EXITLEVEL_SETEXIT ||
|
||||
iValue == HB_EXITLEVEL_DELTARGET ) )
|
||||
hb_comp_iExitLevel = iValue;
|
||||
else
|
||||
fError = TRUE;
|
||||
}
|
||||
/* xHarbour extension */
|
||||
else if( i >= 4 && hb_strnicmp( szSwitch, "TEXTHIDDEN", i ) == 0 &&
|
||||
iValue >= 0 && iValue <= 1 )
|
||||
hb_comp_iHidden = iValue;
|
||||
else
|
||||
fError = TRUE;
|
||||
|
||||
return fError;
|
||||
}
|
||||
|
||||
|
||||
void hb_pp_SetRules( BOOL fQuiet, int argc, char * argv[] )
|
||||
{
|
||||
char * szStdCh = hb_pp_STD_CH;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_pp_SetRules()" ) );
|
||||
|
||||
if( szStdCh && * szStdCh <= ' ' )
|
||||
szStdCh = "";
|
||||
|
||||
hb_pp_Free();
|
||||
s_pp_state = hb_pp_new();
|
||||
if( s_pp_state )
|
||||
{
|
||||
hb_pp_init( s_pp_state, szStdCh, fQuiet,
|
||||
hb_pp_IncludeOpen, hb_pp_IncludeClose,
|
||||
hb_pp_ErrorGen, NULL, hb_pp_PragmaDump,
|
||||
hb_pp_CompilerSwitch );
|
||||
|
||||
/* Add /D and /undef: command line or envvar defines */
|
||||
hb_compChkDefines( argc, argv );
|
||||
|
||||
/* mark current rules as standard ones */
|
||||
hb_pp_setStdBase( s_pp_state );
|
||||
}
|
||||
|
||||
if( hb_comp_pFileName )
|
||||
{
|
||||
hb_xfree( ( void * ) hb_comp_pFileName );
|
||||
hb_comp_pFileName = NULL;
|
||||
}
|
||||
if( hb_pp_STD_CH )
|
||||
{
|
||||
hb_xfree( hb_pp_STD_CH );
|
||||
hb_pp_STD_CH = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void hb_pp_Init( void )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_pp_Init()" ) );
|
||||
|
||||
if( s_pp_state )
|
||||
{
|
||||
hb_pp_reset( s_pp_state );
|
||||
}
|
||||
}
|
||||
|
||||
void hb_pp_Free( void )
|
||||
{
|
||||
if( s_pp_state )
|
||||
{
|
||||
hb_pp_free( s_pp_state );
|
||||
s_pp_state = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void hb_pp_AddDefine( char *defname, char *value )
|
||||
{
|
||||
if( s_pp_state )
|
||||
hb_pp_addDefine( s_pp_state, defname, value );
|
||||
}
|
||||
|
||||
void hb_pp_ParseDirective( char * szLine )
|
||||
{
|
||||
if( s_pp_state && szLine )
|
||||
hb_pp_parseLine( s_pp_state, szLine, NULL );
|
||||
}
|
||||
|
||||
int hb_pp_Internal( FILE * handl_o, char * sOut )
|
||||
{
|
||||
ULONG ulLen = 0;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_pp_Internal(%p, %s)", handl_o, sOut));
|
||||
|
||||
hb_pp_StreamBlock = 0;
|
||||
hb_pp_NestedLiteralString = FALSE;
|
||||
hb_pp_LiteralEscSeq = FALSE;
|
||||
|
||||
if( s_pp_state && hb_comp_files.iFiles > 0 )
|
||||
{
|
||||
char * szLine;
|
||||
|
||||
if( ! hb_pp_fileName( s_pp_state ) )
|
||||
{
|
||||
hb_pp_inFile( s_pp_state, hb_comp_files.pLast->szFileName,
|
||||
hb_comp_files.pLast->handle );
|
||||
}
|
||||
if( handl_o && ! hb_pp_outFileName( s_pp_state ) )
|
||||
{
|
||||
char szOutFileName[ _POSIX_PATH_MAX + 1 ];
|
||||
if( hb_comp_pFilePpo )
|
||||
hb_fsFNameMerge( szOutFileName, hb_comp_pFilePpo );
|
||||
else
|
||||
szOutFileName[ 0 ] = '\0';
|
||||
hb_pp_outFile( s_pp_state, szOutFileName, handl_o );
|
||||
/* dirty hack but works as workaround for pure PP and compiler
|
||||
API integration */
|
||||
if( handl_o == hb_comp_yyppo )
|
||||
hb_comp_yyppo = NULL;
|
||||
}
|
||||
|
||||
szLine = hb_pp_nextLine( s_pp_state, &ulLen );
|
||||
/* I do not know why but compiler expect line number 1 bigger then
|
||||
real line number */
|
||||
hb_comp_iLine = hb_pp_line( s_pp_state ) + 1;
|
||||
|
||||
if( ulLen >= HB_PP_STR_SIZE )
|
||||
hb_compGenError( hb_comp_szErrors, 'F', HB_COMP_ERR_BUFFER_OVERFLOW, NULL, NULL );
|
||||
else if( szLine )
|
||||
memcpy( sOut, szLine, ulLen + 1 );
|
||||
else
|
||||
* sOut = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
* sOut = '\0';
|
||||
}
|
||||
|
||||
if( hb_comp_iLineINLINE && hb_pp_StreamBlock == 0 )
|
||||
{
|
||||
hb_comp_iLineINLINE = 0;
|
||||
}
|
||||
|
||||
return ulLen;
|
||||
}
|
||||
@@ -5,12 +5,16 @@
|
||||
ROOT = ../../
|
||||
|
||||
C_SOURCES=\
|
||||
ppcore.c \
|
||||
ppcomp.c \
|
||||
pplib.c \
|
||||
pptable.c \
|
||||
pragma.c \
|
||||
ppcore.c \
|
||||
|
||||
LIBNAME=pp
|
||||
|
||||
LIBS=\
|
||||
common \
|
||||
|
||||
include $(TOP)$(ROOT)config/lib.cf
|
||||
|
||||
pptable.c : ppgen$(EXE_EXT)
|
||||
./ppgen$(EXE_EXT) $(TOP)$(ROOT)include/hbstdgen.ch -opptable.c -q
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
396
harbour/source/pp/ppgen.c
Normal file
396
harbour/source/pp/ppgen.c
Normal file
@@ -0,0 +1,396 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
*
|
||||
*
|
||||
* Copyright 2006 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ppcore.c"
|
||||
|
||||
|
||||
/*
|
||||
* library functions used by PP core code
|
||||
* necessary to create stand alone binries
|
||||
*/
|
||||
void * hb_xgrab( ULONG ulSize ) { return malloc( ulSize ); }
|
||||
void * hb_xrealloc( void * pMem, ULONG ulSize ) { return realloc( pMem, ulSize ); }
|
||||
void hb_xfree( void * pMem ) { free( pMem ); }
|
||||
|
||||
|
||||
void hb_pp_initStaticRules( PHB_PP_STATE pState )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( pState );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* functions to create .c files with rules defined in given PP context
|
||||
*/
|
||||
static int hb_pp_writeTokenCount( PHB_PP_TOKEN pToken )
|
||||
{
|
||||
int iToken = 0;
|
||||
while( pToken )
|
||||
{
|
||||
iToken += hb_pp_writeTokenCount( pToken->pMTokens ) + 1;
|
||||
pToken = pToken->pNext;
|
||||
}
|
||||
return iToken;
|
||||
}
|
||||
|
||||
static void hb_pp_writeToken( FILE * fout, PHB_PP_TOKEN pToken,
|
||||
char * szName, int iToken, BOOL fLast )
|
||||
{
|
||||
while( pToken )
|
||||
{
|
||||
int iOptional = hb_pp_writeTokenCount( pToken->pMTokens ), i;
|
||||
|
||||
i = strlen( szName );
|
||||
if( pToken->pNext )
|
||||
fprintf( fout, " { %s +%2d", szName, iToken + iOptional + 1 );
|
||||
else
|
||||
fprintf( fout, " { NULL%*.s", i, "" );
|
||||
if( iOptional )
|
||||
fprintf( fout, ", %s +%2d", szName, iToken + 1 );
|
||||
else
|
||||
fprintf( fout, ", NULL%*.s", i, "" );
|
||||
|
||||
i = 16 - strlen( pToken->value );
|
||||
fprintf( fout, ", \"%s\", %*.s %2d,%2d, 0x%04x, %d }%s\n",
|
||||
pToken->value,
|
||||
i < 0 ? 0 : i, "",
|
||||
pToken->len, pToken->spaces,
|
||||
pToken->type | HB_PP_TOKEN_STATIC | HB_PP_TOKEN_PREDEFINED,
|
||||
pToken->index,
|
||||
fLast && !pToken->pNext && iOptional == 0 ? "" : "," );
|
||||
|
||||
if( iOptional )
|
||||
hb_pp_writeToken( fout, pToken->pMTokens, szName, iToken + 1,
|
||||
pToken->pNext == NULL && fLast );
|
||||
|
||||
iToken += iOptional + 1;
|
||||
pToken = pToken->pNext;
|
||||
}
|
||||
}
|
||||
|
||||
static void hb_pp_writeTokenList( FILE * fout, PHB_PP_TOKEN pTokenLst, char * szName )
|
||||
{
|
||||
int iTokens;
|
||||
|
||||
iTokens = hb_pp_writeTokenCount( pTokenLst );
|
||||
if( iTokens )
|
||||
{
|
||||
fprintf( fout, "static HB_PP_TOKEN %s[ %d ] = {\n",
|
||||
szName, iTokens );
|
||||
hb_pp_writeToken( fout, pTokenLst, szName, 0, TRUE );
|
||||
fprintf( fout, "};\n" );
|
||||
}
|
||||
}
|
||||
|
||||
static int hb_pp_writeRules( FILE * fout, PHB_PP_RULE pFirst, char * szName )
|
||||
{
|
||||
char szMatch[ 16 ], szResult[ 16 ];
|
||||
ULONG ulRepeatBits, ulBit;
|
||||
PHB_PP_RULE pRule;
|
||||
int iRule;
|
||||
USHORT u;
|
||||
|
||||
iRule = 0;
|
||||
pRule = pFirst;
|
||||
while( pRule )
|
||||
{
|
||||
++iRule;
|
||||
if( pRule->pMatch )
|
||||
{
|
||||
sprintf( szMatch, "s_%cm%03d", szName[0], iRule );
|
||||
hb_pp_writeTokenList( fout, pRule->pMatch, szMatch );
|
||||
}
|
||||
|
||||
if( pRule->pResult )
|
||||
{
|
||||
sprintf( szResult, "s_%cr%03d", szName[0], iRule );
|
||||
hb_pp_writeTokenList( fout, pRule->pResult, szResult );
|
||||
}
|
||||
pRule = pRule->pPrev;
|
||||
}
|
||||
|
||||
fprintf( fout, "static const HB_PP_DEFRULE s_%s[ %d ] = {\n",
|
||||
szName, iRule );
|
||||
|
||||
iRule = 0;
|
||||
pRule = pFirst;
|
||||
while( pRule )
|
||||
{
|
||||
++iRule;
|
||||
if( pRule->pMatch )
|
||||
sprintf( szMatch, "s_%cm%03d", szName[0], iRule );
|
||||
else
|
||||
strcpy( szMatch, "NULL " );
|
||||
if( pRule->pResult )
|
||||
sprintf( szResult, "s_%cr%03d", szName[0], iRule );
|
||||
else
|
||||
strcpy( szResult, "NULL " );
|
||||
|
||||
ulRepeatBits = 0;
|
||||
for( u = 0, ulBit = 1; u < pRule->markers; ++u, ulBit <<= 1 )
|
||||
{
|
||||
if( pRule->pMarkers[ u ].canrepeat )
|
||||
ulRepeatBits |= ulBit;
|
||||
}
|
||||
fprintf( fout, " { %s, %s, %d,%2d, 0x%04lx }%s\n",
|
||||
szMatch, szResult, HB_PP_CMP_MODE( pRule->mode ),
|
||||
pRule->markers, ulRepeatBits, pRule->pPrev ? "," : "" );
|
||||
pRule = pRule->pPrev;
|
||||
}
|
||||
fprintf( fout, "};\n\n" );
|
||||
return iRule;
|
||||
}
|
||||
|
||||
static void hb_pp_generateInitFunc( FILE * fout, int iRules,
|
||||
char * szVar, char * szRule )
|
||||
{
|
||||
fprintf( fout, " hb_pp_initRules( &pState->p%s, &pState->i%s, ",
|
||||
szVar, szVar );
|
||||
if( iRules )
|
||||
fprintf( fout, "s_%s, %d );\n", szRule, iRules );
|
||||
else
|
||||
fprintf( fout, "NULL, 0 );\n" );
|
||||
}
|
||||
|
||||
static void hb_pp_generateRules( FILE * fout, PHB_PP_STATE pState )
|
||||
{
|
||||
int iDefs = 0, iTrans = 0, iCmds = 0;
|
||||
|
||||
fprintf( fout, "/*\n * $Id$\n */\n\n/*\n"
|
||||
" * Harbour Project source code:\n"
|
||||
" * Build in preprocessor rules.\n"
|
||||
" *\n"
|
||||
" * Copyright 2006 Przemyslaw Czerpak <druzus / at / priv.onet.pl>\n"
|
||||
" * www - http://www.harbour-project.org\n"
|
||||
" *\n"
|
||||
" * This file is generate automatically by Harbour preprocessor\n"
|
||||
" * and is covered by the same license as Harbour PP\n"
|
||||
" */\n\n#define _HB_PP_INTERNAL\n#include \"hbpp.h\"\n\n" );
|
||||
|
||||
if( pState->pDefinitions )
|
||||
iDefs = hb_pp_writeRules( fout, pState->pDefinitions, "def" );
|
||||
if( pState->pTranslations )
|
||||
iTrans = hb_pp_writeRules( fout, pState->pTranslations, "trs" );
|
||||
if( pState->pCommands )
|
||||
iCmds = hb_pp_writeRules( fout, pState->pCommands, "cmd" );
|
||||
|
||||
fprintf( fout, "\nvoid hb_pp_initStaticRules( PHB_PP_STATE pState )\n{\n" );
|
||||
hb_pp_generateInitFunc( fout, iDefs, "Definitions", "def" );
|
||||
hb_pp_generateInitFunc( fout, iTrans, "Translations", "trs" );
|
||||
hb_pp_generateInitFunc( fout, iCmds, "Commands", "cmd" );
|
||||
fprintf( fout, "}\n" );
|
||||
}
|
||||
|
||||
static void hb_pp_undefCompilerRules( PHB_PP_STATE pState )
|
||||
{
|
||||
int i;
|
||||
PHB_PP_RULE * pRulePtr, pRule;
|
||||
char * szRules[] = { "__HARBOUR__",
|
||||
"__DATE__",
|
||||
"__TIME__",
|
||||
"__HB_MAIN__",
|
||||
"__ARCH16BIT__",
|
||||
"__ARCH32BIT__",
|
||||
"__ARCH64BIT__",
|
||||
"__LITTLE_ENDIAN__",
|
||||
"__BIG_ENDIAN__",
|
||||
"__PDP_ENDIAN__",
|
||||
NULL };
|
||||
|
||||
for( i = 0; szRules[ i ]; ++i )
|
||||
hb_pp_delDefine( pState, szRules[ i ] );
|
||||
|
||||
pRulePtr = &pState->pDefinitions;
|
||||
while( * pRulePtr )
|
||||
{
|
||||
pRule = *pRulePtr;
|
||||
if( !pRule->pMatch->pNext &&
|
||||
strncmp( pRule->pMatch->value, "__PLATFORM__", 12 ) == 0 )
|
||||
{
|
||||
* pRulePtr = pRule->pPrev;
|
||||
hb_pp_ruleFree( pRule );
|
||||
pState->iDefinitions--;
|
||||
}
|
||||
else
|
||||
pRulePtr = &pRule->pPrev;
|
||||
}
|
||||
}
|
||||
|
||||
static int hb_pp_preprocesfile( PHB_PP_STATE pState, char * szRuleFile )
|
||||
{
|
||||
int iResult = 0;
|
||||
ULONG ulLen;
|
||||
|
||||
while( hb_pp_nextLine( pState, &ulLen ) != NULL && ulLen );
|
||||
|
||||
if( szRuleFile )
|
||||
{
|
||||
FILE * foutr;
|
||||
|
||||
foutr = fopen( szRuleFile, "w" );
|
||||
if( !foutr )
|
||||
{
|
||||
perror( szRuleFile );
|
||||
iResult = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_pp_undefCompilerRules( pState );
|
||||
hb_pp_generateRules( foutr, pState );
|
||||
fclose( foutr );
|
||||
}
|
||||
}
|
||||
|
||||
return iResult;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ppgen only functions
|
||||
*/
|
||||
static void hb_pp_usage( char * szName )
|
||||
{
|
||||
printf( "Syntax: %s <file>[.prg] [options]\n\n", szName );
|
||||
printf( "Options: -i<path> \tadd #include file search path\n"
|
||||
" -o[<file>]\tcreates .c file with PP rules\n"
|
||||
" -w \twrite preprocessed (.ppo) input file\n"
|
||||
" -q \tdisable information messages\n" );
|
||||
}
|
||||
|
||||
int main( int argc, char * argv[] )
|
||||
{
|
||||
char * szFile = NULL, * szRuleFile = NULL;
|
||||
BOOL fQuiet = FALSE, fWrite = FALSE;
|
||||
PHB_PP_STATE pState;
|
||||
int iResult, i;
|
||||
|
||||
pState = hb_pp_new();
|
||||
|
||||
if( argc >= 2 )
|
||||
{
|
||||
szFile = argv[1];
|
||||
for( i = 2; szFile && i < argc; i++ )
|
||||
{
|
||||
if( !HB_ISOPTSEP( argv[i][0] ) )
|
||||
szFile = NULL;
|
||||
else
|
||||
{
|
||||
switch( argv[i][1] )
|
||||
{
|
||||
case 'q':
|
||||
case 'Q':
|
||||
if( argv[i][2] )
|
||||
szFile = NULL;
|
||||
else
|
||||
fQuiet = TRUE;
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
case 'W':
|
||||
if( argv[i][2] )
|
||||
szFile = NULL;
|
||||
else
|
||||
fWrite = TRUE;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
case 'I':
|
||||
if( argv[i][2] )
|
||||
hb_pp_addSearchPath( pState, argv[i] + 2, FALSE );
|
||||
else
|
||||
szFile = NULL;
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
case 'O':
|
||||
if( argv[i][2] )
|
||||
szRuleFile = argv[i] + 2;
|
||||
else
|
||||
szFile = NULL;
|
||||
break;
|
||||
|
||||
default:
|
||||
szFile = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( szFile )
|
||||
{
|
||||
hb_pp_init( pState, NULL, fQuiet, NULL, NULL, NULL, NULL, NULL, NULL );
|
||||
hb_pp_inFile( pState, szFile, NULL );
|
||||
if( fWrite )
|
||||
{
|
||||
char szFileName[ _POSIX_PATH_MAX + 1 ];
|
||||
PHB_FNAME pFileName;
|
||||
|
||||
pFileName = hb_fsFNameSplit( szFile );
|
||||
pFileName->szExtension = ".ppo";
|
||||
hb_fsFNameMerge( szFileName, pFileName );
|
||||
hb_xfree( pFileName );
|
||||
|
||||
hb_pp_outFile( pState, szFileName, NULL );
|
||||
}
|
||||
iResult = hb_pp_preprocesfile( pState, szRuleFile );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_pp_usage( argv[0] );
|
||||
iResult = 1;
|
||||
}
|
||||
|
||||
hb_pp_free( pState );
|
||||
|
||||
return iResult;
|
||||
}
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Preprocessor runtime library callable version
|
||||
*
|
||||
*
|
||||
* Copyright 1999 Felipe G. Coury <fcoury@creation.com.br>
|
||||
* Copyright 2006 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -50,216 +50,169 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Avoid tracing in preprocessor/compiler.
|
||||
*/
|
||||
#if ! defined(HB_TRACE_UTILS)
|
||||
#if defined(HB_TRACE_LEVEL)
|
||||
#undef HB_TRACE_LEVEL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
/* #include <setjmp.h> */
|
||||
|
||||
#include "hbpp.h"
|
||||
#include "hbcomp.h"
|
||||
#include "hbapi.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapifs.h"
|
||||
#include "hbapierr.h"
|
||||
#include "hbvm.h"
|
||||
|
||||
#ifdef HB_EXTENSION
|
||||
static PHB_PP_STATE s_pp_state = NULL;
|
||||
|
||||
HB_PATHNAMES * hb_comp_pIncludePath = NULL;
|
||||
PHB_FNAME hb_comp_pFileName = NULL;
|
||||
FILES hb_comp_files;
|
||||
int hb_comp_iLine; /* currently parsed file line number */
|
||||
int hb_comp_iLinePRG;
|
||||
int hb_comp_iLineINLINE = 0;
|
||||
static void hb_pp_ErrorMessage( char * szMsgTable[], char cPrefix, int iCode,
|
||||
const char * szParam1, const char * szParam2 )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_pp_ErrorGen(%p, %c, %d, %s, %s)", szMsgTable, cPrefix, iCode, szParam1, szParam2));
|
||||
|
||||
/* These are need for the PP #pragma support */
|
||||
BOOL hb_comp_bPPO = FALSE; /* flag indicating, is ppo output needed */
|
||||
BOOL hb_comp_bStartProc = TRUE; /* holds if we need to create the starting procedure */
|
||||
BOOL hb_comp_bLineNumbers = TRUE; /* holds if we need pcodes with line numbers */
|
||||
/* ignore warning messages */
|
||||
if( cPrefix != 'W' )
|
||||
{
|
||||
char szMsgBuf[ 1024 ];
|
||||
PHB_ITEM pError;
|
||||
sprintf( szMsgBuf, szMsgTable[ iCode - 1 ], szParam1, szParam2 );
|
||||
pError = hb_errRT_New( ES_ERROR, "PP", 9999, ( ULONG ) iCode, szMsgBuf,
|
||||
NULL, 0, EF_NONE | EF_CANDEFAULT );
|
||||
hb_errLaunch( pError );
|
||||
hb_errRelease( pError );
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
BOOL hb_comp_bShortCuts = TRUE; /* .and. & .or. expressions shortcuts */
|
||||
#endif
|
||||
static void hb_pp_Disp( const char * szMessage )
|
||||
{
|
||||
/* ignore stdout messages when PP used as library */
|
||||
HB_SYMBOL_UNUSED( szMessage );
|
||||
}
|
||||
|
||||
int hb_comp_iWarnings = 0; /* enable parse warnings */
|
||||
BOOL hb_comp_bAutoMemvarAssume = FALSE; /* holds if undeclared variables are automatically assumed MEMVAR (-a)*/
|
||||
BOOL hb_comp_bForceMemvars = FALSE; /* holds if memvars are assumed when accesing undeclared variable (-v)*/
|
||||
BOOL hb_comp_bDebugInfo = FALSE; /* holds if generate debugger required info */
|
||||
int hb_comp_iExitLevel = HB_EXITLEVEL_DEFAULT; /* holds if there was any warning during the compilation process */
|
||||
FILE * hb_comp_yyppo = NULL;
|
||||
static PHB_PP_STATE hb_pp_stateParam( int * piParam )
|
||||
{
|
||||
PHB_ITEM pItem = hb_parptr( 1 );
|
||||
|
||||
/* static jmp_buf s_env; */
|
||||
if( pItem )
|
||||
{
|
||||
* piParam = 2;
|
||||
return ( PHB_PP_STATE ) hb_itemGetPtr( pItem );
|
||||
}
|
||||
else
|
||||
{
|
||||
* piParam = 1;
|
||||
if( !s_pp_state )
|
||||
{
|
||||
s_pp_state = hb_pp_new();
|
||||
hb_pp_init( s_pp_state, NULL, TRUE, NULL, NULL,
|
||||
hb_pp_ErrorMessage, hb_pp_Disp, NULL, NULL );
|
||||
}
|
||||
return s_pp_state;
|
||||
}
|
||||
}
|
||||
|
||||
HB_FUNC( __PP_INIT )
|
||||
{
|
||||
hb_pp_Table();
|
||||
hb_pp_Init();
|
||||
hb_comp_files.iFiles = 0;
|
||||
PHB_PP_STATE pState;
|
||||
int iParam;
|
||||
|
||||
if( ISCHAR( 1 ) )
|
||||
pState = hb_pp_stateParam( &iParam );
|
||||
if( pState )
|
||||
{
|
||||
hb_fsAddSearchPath( hb_parc( 1 ), &hb_comp_pIncludePath );
|
||||
hb_pp_reset( pState );
|
||||
|
||||
if( ISCHAR( iParam ) )
|
||||
hb_pp_addSearchPath( pState, hb_parc( iParam ), TRUE );
|
||||
|
||||
hb_retptr( pState );
|
||||
}
|
||||
else
|
||||
hb_ret();
|
||||
}
|
||||
|
||||
HB_FUNC( __PP_FREE )
|
||||
{
|
||||
PHB_ITEM pItem = hb_parptr( 1 );
|
||||
|
||||
if( pItem )
|
||||
{
|
||||
PHB_PP_STATE pState = ( PHB_PP_STATE ) hb_itemGetPtr( pItem );
|
||||
if( pState )
|
||||
hb_pp_free( pState );
|
||||
}
|
||||
else if( s_pp_state )
|
||||
{
|
||||
hb_pp_free( s_pp_state );
|
||||
s_pp_state = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
HB_FUNC( __PP_PATH )
|
||||
{
|
||||
if( ISLOG( 2 ) && hb_parl( 2 ) && hb_comp_pIncludePath )
|
||||
{
|
||||
hb_fsFreeSearchPath( hb_comp_pIncludePath );
|
||||
hb_comp_pIncludePath = NULL;
|
||||
}
|
||||
PHB_PP_STATE pState;
|
||||
int iParam;
|
||||
|
||||
if( ISCHAR( 1 ) )
|
||||
pState = hb_pp_stateParam( &iParam );
|
||||
if( pState )
|
||||
{
|
||||
hb_fsAddSearchPath( hb_parc( 1 ), &hb_comp_pIncludePath );
|
||||
}
|
||||
}
|
||||
|
||||
HB_FUNC( __PP_FREE )
|
||||
{
|
||||
if( hb_comp_pIncludePath )
|
||||
{
|
||||
hb_fsFreeSearchPath( hb_comp_pIncludePath );
|
||||
hb_comp_pIncludePath = NULL;
|
||||
}
|
||||
|
||||
hb_pp_Free();
|
||||
|
||||
if( hb_pp_aCondCompile )
|
||||
{
|
||||
hb_xfree( hb_pp_aCondCompile );
|
||||
hb_pp_aCondCompile = NULL;
|
||||
hb_pp_addSearchPath( pState, hb_parc( iParam ), hb_parl( iParam + 1 ) );
|
||||
}
|
||||
}
|
||||
|
||||
HB_FUNC( __PPADDRULE )
|
||||
{
|
||||
if( ISCHAR( 1 ) )
|
||||
{
|
||||
char * ptr = hb_parc( 1 );
|
||||
char * hb_buffer;
|
||||
PHB_PP_STATE pState;
|
||||
int iParam;
|
||||
|
||||
HB_SKIPTABSPACES( ptr );
|
||||
if( *ptr == '#' )
|
||||
pState = hb_pp_stateParam( &iParam );
|
||||
if( pState )
|
||||
{
|
||||
char * szText = hb_parc( iParam );
|
||||
ULONG ulLen = hb_parclen( iParam );
|
||||
|
||||
if( szText )
|
||||
{
|
||||
if( !hb_pp_aCondCompile )
|
||||
while( ulLen && ( szText[ 0 ] == ' ' || szText[ 0 ] == '\t' ) )
|
||||
{
|
||||
hb_pp_Table();
|
||||
hb_pp_Init();
|
||||
hb_comp_files.iFiles = 0;
|
||||
++szText;
|
||||
--ulLen;
|
||||
}
|
||||
hb_pp_ParseDirective( ptr );
|
||||
if( hb_comp_files.pLast )
|
||||
{
|
||||
hb_buffer = ( char* ) hb_xgrab( HB_PP_STR_SIZE );
|
||||
while( hb_pp_Internal( NULL,hb_buffer ) > 0 );
|
||||
hb_pp_CloseInclude();
|
||||
hb_xfree( hb_buffer );
|
||||
}
|
||||
hb_retl( 1 );
|
||||
}
|
||||
else
|
||||
hb_retl( 0 );
|
||||
|
||||
if( szText && ulLen && szText[ 0 ] == '#' )
|
||||
{
|
||||
hb_pp_reset( pState );
|
||||
hb_pp_parseLine( pState, szText, &ulLen );
|
||||
|
||||
/* probably for #included files parsing the old code was making
|
||||
sth like that */
|
||||
do
|
||||
{
|
||||
if( hb_vmRequestQuery() != 0 )
|
||||
return;
|
||||
}
|
||||
while( hb_pp_nextLine( pState, NULL ) );
|
||||
|
||||
hb_retl( TRUE );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
hb_retl( 0 );
|
||||
hb_retl( FALSE );
|
||||
}
|
||||
|
||||
HB_FUNC( __PREPROCESS )
|
||||
{
|
||||
if( ISCHAR( 1 ) )
|
||||
PHB_PP_STATE pState;
|
||||
int iParam;
|
||||
|
||||
pState = hb_pp_stateParam( &iParam );
|
||||
if( pState )
|
||||
{
|
||||
char * pText = ( char * ) hb_xgrab( HB_PP_STR_SIZE );
|
||||
char * pOut = ( char * ) hb_xgrab( HB_PP_STR_SIZE );
|
||||
char * szText = hb_parc( iParam );
|
||||
ULONG ulLen = hb_parclen( iParam );
|
||||
|
||||
/* if( setjmp( s_env ) == 0 ) */
|
||||
{
|
||||
char * ptr = pText;
|
||||
int slen;
|
||||
|
||||
/* hb_pp_Init(); */
|
||||
|
||||
slen = HB_MIN( hb_parclen( 1 ), HB_PP_STR_SIZE - 1 );
|
||||
memcpy( pText, hb_parc( 1 ), slen );
|
||||
pText[ slen ] = 0; /* Preprocessor expects null-terminated string */
|
||||
if( slen )
|
||||
{
|
||||
memset( pOut, 0, HB_PP_STR_SIZE );
|
||||
|
||||
HB_SKIPTABSPACES( ptr );
|
||||
|
||||
if( !hb_pp_topDefine )
|
||||
hb_pp_Table();
|
||||
if( *ptr && hb_pp_ParseExpression( ptr, pOut, FALSE ) > 0 )
|
||||
{
|
||||
/* Some error here? */
|
||||
}
|
||||
}
|
||||
hb_retc( pText ); /* Preprocessor returns parsed line in input buffer */
|
||||
if( szText && ulLen )
|
||||
{
|
||||
szText = hb_pp_parseLine( pState, szText, &ulLen );
|
||||
hb_retclen( szText, ulLen );
|
||||
return;
|
||||
}
|
||||
/* else
|
||||
{ */
|
||||
/* an error occured during parsing.
|
||||
* The longjmp was used in GenError()
|
||||
*/
|
||||
/* hb_retc( NULL );
|
||||
} */
|
||||
|
||||
hb_xfree( pText );
|
||||
hb_xfree( pOut );
|
||||
}
|
||||
else
|
||||
hb_retc( NULL );
|
||||
|
||||
hb_retc( NULL );
|
||||
}
|
||||
|
||||
void hb_compGenError( char * szErrors[], char cPrefix, int iError, const char * szError1, const char * szError2 )
|
||||
{
|
||||
PHB_ITEM pError;
|
||||
char buffer[ 128 ];
|
||||
|
||||
HB_SYMBOL_UNUSED( cPrefix );
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_compGenError(%p, %c, %d, %s, %s)", szErrors, cPrefix, iError, szError1, szError2));
|
||||
|
||||
/* TOFIX: The internal buffers allocated by the preprocessor should be
|
||||
deallocated here */
|
||||
|
||||
sprintf( buffer, szErrors[ iError - 1 ], szError1, szError2 );
|
||||
pError = hb_errRT_New( ES_ERROR, "PP", 9999, ( ULONG ) iError, buffer, NULL, 0, EF_NONE | EF_CANDEFAULT );
|
||||
hb_errLaunch( pError );
|
||||
hb_errRelease( pError );
|
||||
|
||||
/* longjmp( s_env, iError == 0 ? -1 : iError ); */
|
||||
}
|
||||
|
||||
void hb_compGenWarning( char * szWarnings[], char cPrefix, int iWarning, const char * szWarning1, const char * szWarning2 )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_compGenWarning(%p, %c, %d, %s, %s)", szWarnings, cPrefix, iWarning, szWarning1, szWarning2));
|
||||
|
||||
/* NOTE: All warnings are simply ignored */
|
||||
|
||||
HB_SYMBOL_UNUSED( szWarnings );
|
||||
HB_SYMBOL_UNUSED( cPrefix );
|
||||
HB_SYMBOL_UNUSED( iWarning );
|
||||
HB_SYMBOL_UNUSED( szWarning1 );
|
||||
HB_SYMBOL_UNUSED( szWarning2 );
|
||||
}
|
||||
|
||||
PINLINE hb_compInlineAdd( char * szFunName )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( szFunName );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void hb_compParserStop( void )
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1362,6 +1362,7 @@ ERRCODE hb_waClearFilter( AREAP pArea )
|
||||
hb_itemRelease( pArea->dbfi.abFilterText );
|
||||
pArea->dbfi.abFilterText = NULL;
|
||||
}
|
||||
pArea->dbfi.fOptimized = FALSE;
|
||||
pArea->dbfi.fFilter = FALSE;
|
||||
|
||||
return SUCCESS;
|
||||
@@ -1446,7 +1447,7 @@ ERRCODE hb_waSetFilter( AREAP pArea, LPDBFILTERINFO pFilterInfo )
|
||||
{
|
||||
pArea->dbfi.abFilterText = hb_itemNew( pFilterInfo->abFilterText );
|
||||
}
|
||||
pArea->dbfi.fOptimized = pArea->dbfi.fOptimized;
|
||||
pArea->dbfi.fOptimized = pFilterInfo->fOptimized;
|
||||
pArea->dbfi.fFilter = TRUE;
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
@@ -54,9 +54,6 @@
|
||||
* The following parts are Copyright of the individual authors.
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* Copyright 1999 Jose Lalin <dezac@corevia.com>
|
||||
* hb_dateDOW()
|
||||
*
|
||||
* Copyright 1999 David G. Holm <dholm@jsd-llc.com>
|
||||
* hb_dateFormat()
|
||||
*
|
||||
@@ -64,10 +61,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#define HB_OS_WIN_32_USED
|
||||
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbdate.h"
|
||||
@@ -243,51 +237,3 @@ HB_EXPORT char * hb_dateFormat( const char * szDate, char * szFormattedDate, con
|
||||
|
||||
return szFormattedDate;
|
||||
}
|
||||
|
||||
HB_EXPORT void hb_dateToday( int * piYear, int * piMonth, int * piDay )
|
||||
{
|
||||
#if defined(HB_OS_WIN_32)
|
||||
{
|
||||
SYSTEMTIME st;
|
||||
GetLocalTime( &st );
|
||||
|
||||
*piYear = st.wYear;
|
||||
*piMonth = st.wMonth;
|
||||
*piDay = st.wDay;
|
||||
}
|
||||
#else
|
||||
{
|
||||
time_t t;
|
||||
struct tm * oTime;
|
||||
|
||||
time( &t );
|
||||
oTime = localtime( &t );
|
||||
|
||||
*piYear = oTime->tm_year + 1900;
|
||||
*piMonth = oTime->tm_mon + 1;
|
||||
*piDay = oTime->tm_mday;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* NOTE: The passed buffer must be at least 9 chars long */
|
||||
|
||||
HB_EXPORT void hb_dateTimeStr( char * pszTime )
|
||||
{
|
||||
#if defined(HB_OS_WIN_32)
|
||||
{
|
||||
SYSTEMTIME st;
|
||||
GetLocalTime( &st );
|
||||
sprintf( pszTime, "%02d:%02d:%02d", st.wHour, st.wMinute, st.wSecond );
|
||||
}
|
||||
#else
|
||||
{
|
||||
time_t t;
|
||||
struct tm * oTime;
|
||||
|
||||
time( &t );
|
||||
oTime = localtime( &t );
|
||||
sprintf( pszTime, "%02d:%02d:%02d", oTime->tm_hour, oTime->tm_min, oTime->tm_sec );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -5,11 +5,14 @@
|
||||
ROOT = ../../
|
||||
|
||||
C_SOURCES=\
|
||||
ppcore.c \
|
||||
ppcomp.c \
|
||||
pptable.c \
|
||||
pragma.c \
|
||||
|
||||
C_MAIN=hbpp.c
|
||||
|
||||
LIBS=\
|
||||
pp \
|
||||
common \
|
||||
|
||||
include $(TOP)$(ROOT)config/bin.cf
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
#include "hbpp.h"
|
||||
#include "hbcomp.h"
|
||||
|
||||
extern int hb_pp_ParseDefine( char * );
|
||||
extern int hb_pp_ParseDefine_( char * );
|
||||
|
||||
static void AddSearchPath( char * szPath, HB_PATHNAMES * * pSearchList );
|
||||
static void OutTable( DEFINES * endDefine, COMMANDS * endCommand );
|
||||
@@ -142,16 +142,16 @@ int main( int argc, char * argv[] )
|
||||
{
|
||||
if( ( pAssign = strchr( szDefText, '=' ) ) == NULL )
|
||||
{
|
||||
hb_pp_AddDefine( szDefText, 0 );
|
||||
hb_pp_AddDefine_( szDefText, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
szDefText[ pAssign - szDefText ] = '\0';
|
||||
|
||||
//hb_pp_AddDefine( szDefText, pAssign + 1 );
|
||||
//hb_pp_AddDefine_( szDefText, pAssign + 1 );
|
||||
sDefLine = (char*) hb_xgrab( strlen( szDefText ) + 1 + strlen( pAssign + 1 ) + 1 );
|
||||
sprintf( sDefLine, "%s %s", szDefText, pAssign + 1 );
|
||||
hb_pp_ParseDefine( sDefLine );
|
||||
hb_pp_ParseDefine_( sDefLine );
|
||||
hb_xfree( sDefLine );
|
||||
}
|
||||
}
|
||||
|
||||
184
harbour/utils/hbpp/hbpp.h
Normal file
184
harbour/utils/hbpp/hbpp.h
Normal file
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Header file for the Preprocesor
|
||||
*
|
||||
* Copyright 1999 Alexander S.Kresin <alex@belacy.belgorod.su>
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HB_PP_H_
|
||||
#define HB_PP_H_
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapifs.h"
|
||||
#include "hberrors.h"
|
||||
#include "hbver.h"
|
||||
|
||||
HB_EXTERN_BEGIN
|
||||
|
||||
struct _DEFINES;
|
||||
typedef struct _DEFINES
|
||||
{
|
||||
char * name;
|
||||
int namelen;
|
||||
char * pars;
|
||||
int npars;
|
||||
char * value;
|
||||
struct _DEFINES * last;
|
||||
} DEFINES;
|
||||
|
||||
struct _COMMANDS;
|
||||
typedef struct _COMMANDS
|
||||
{
|
||||
int com_or_xcom;
|
||||
char * name;
|
||||
int namelen;
|
||||
char * mpatt;
|
||||
char * value;
|
||||
struct _COMMANDS * last;
|
||||
} COMMANDS;
|
||||
|
||||
#define HB_PP_STR_SIZE 12288
|
||||
#define HB_PP_BUFF_SIZE 4096
|
||||
|
||||
#define HB_SKIPTABSPACES( sptr ) while( *( sptr ) == ' ' || *( sptr ) == '\t' ) ( sptr )++
|
||||
|
||||
/* PPCORE.C exported functions and variables */
|
||||
|
||||
#define HB_INCLUDE_FUNC_( hbFunc ) BOOL hbFunc( char *, HB_PATHNAMES * )
|
||||
typedef HB_INCLUDE_FUNC_( HB_INCLUDE_FUNC );
|
||||
typedef HB_INCLUDE_FUNC * HB_INCLUDE_FUNC_PTR;
|
||||
|
||||
extern void hb_pp_SetRules_( HB_INCLUDE_FUNC_PTR hb_compInclude, BOOL hb_comp_bQuiet );
|
||||
extern int hb_pp_ReadRules( void );
|
||||
extern void hb_pp_Init( void );
|
||||
extern void hb_pp_Free( void );
|
||||
extern void hb_pp_CloseInclude( void );
|
||||
extern int hb_pp_ParseDirective_( char * ); /* Parsing preprocessor directives ( #... ) */
|
||||
extern int hb_pp_ParseExpression( char *, char *, BOOL ); /* Parsing a line ( without preprocessor directive ) */
|
||||
extern int hb_pp_WrStr( FILE *, char * );
|
||||
extern int hb_pp_RdStr( FILE *, char *, int, BOOL, char *, int *, int * );
|
||||
extern void hb_pp_Stuff( char *, char *, int, int, int );
|
||||
extern int hb_pp_strocpy( char *, char * );
|
||||
extern DEFINES * hb_pp_AddDefine_( char *, char * ); /* Add new #define to a linked list */
|
||||
|
||||
extern int hb_pp_lInclude;
|
||||
extern int * hb_pp_aCondCompile;
|
||||
extern int hb_pp_nCondCompile;
|
||||
extern char * hb_pp_szErrors[];
|
||||
extern char * hb_pp_szWarnings[];
|
||||
extern int hb_pp_nEmptyStrings;
|
||||
extern int hb_pp_LastOutLine;
|
||||
extern int hb_pp_StreamBlock;
|
||||
extern BOOL hb_pp_NestedLiteralString;
|
||||
extern BOOL hb_pp_LiteralEscSeq;
|
||||
extern unsigned int hb_pp_MaxTranslateCycles;
|
||||
|
||||
/* PPCOMP.C exported functions */
|
||||
|
||||
extern int hb_pp_Internal( FILE *, char * );
|
||||
extern void hb_pp_InternalFree( void );
|
||||
|
||||
#if 0
|
||||
#define HB_PP_STREAM_DUMP_C 1 /* pragma BEGINDUMP */
|
||||
#define HB_PP_STREAM_CLIPPER 2 /* clipper compatible TEXT/ENDTEXT */
|
||||
#define HB_PP_STREAM_PRG 4 /* TEXT/ENDTEXT lines joined with LF */
|
||||
#define HB_PP_STREAM_C 8 /* TEXT/ENDTEXT lines joined and ESC seq processed */
|
||||
#else
|
||||
#define HB_PP_STREAM_DUMP_C 2 /* pragma BEGINDUMP */
|
||||
#define HB_PP_STREAM_CLIPPER 3 /* clipper compatible TEXT/ENDTEXT */
|
||||
#define HB_PP_STREAM_PRG 4 /* TEXT/ENDTEXT lines joined with LF */
|
||||
#define HB_PP_STREAM_C 5 /* TEXT/ENDTEXT lines joined and ESC seq processed */
|
||||
#endif
|
||||
|
||||
extern BOOL hb_pp_StreamBlockBegin( char *, int );
|
||||
extern void hb_pp_BlockEnd( void );
|
||||
|
||||
/* PPTABLE.C exported functions and variables */
|
||||
|
||||
extern void hb_pp_Table( void );
|
||||
|
||||
extern DEFINES * hb_pp_topDefine;
|
||||
extern COMMANDS * hb_pp_topCommand;
|
||||
extern COMMANDS * hb_pp_topTranslate;
|
||||
|
||||
/* PRAGMA.C exported functions */
|
||||
|
||||
extern BOOL hb_pp_ParsePragma( char * szline );
|
||||
|
||||
/*
|
||||
* Errors generated by Harbour preprocessor
|
||||
*/
|
||||
#define HB_PP_ERR_CANNOT_OPEN 1
|
||||
#define HB_PP_ERR_DIRECTIVE_ELSE 2
|
||||
#define HB_PP_ERR_DIRECTIVE_ENDIF 3
|
||||
#define HB_PP_ERR_WRONG_NAME 4
|
||||
#define HB_PP_ERR_DEFINE_ABSENT 5
|
||||
#define HB_PP_ERR_COMMAND_DEFINITION 6
|
||||
#define HB_PP_ERR_PATTERN_DEFINITION 7
|
||||
#define HB_PP_ERR_RECURSE 8
|
||||
#define HB_PP_ERR_WRONG_DIRECTIVE 9
|
||||
#define HB_PP_ERR_EXPLICIT 10
|
||||
#define HB_PP_ERR_MEMALLOC 11
|
||||
#define HB_PP_ERR_MEMREALLOC 12
|
||||
#define HB_PP_ERR_MEMFREE 13
|
||||
#define HB_PP_ERR_PRAGMA_BAD_VALUE 14
|
||||
#define HB_PP_ERR_CANNOT_OPEN_RULES 15
|
||||
#define HB_PP_ERR_BAD_RULES_FILE_NAME 16
|
||||
#define HB_PP_ERR_TOO_MANY_INCLUDES 17
|
||||
#define HB_PP_ERR_BUFFER_OVERFLOW 18
|
||||
#define HB_PP_ERR_LABEL_MISSING_IN_DEFINE 19
|
||||
#define HB_PP_ERR_PARE_MISSING_IN_DEFINE 20
|
||||
#define HB_PP_ERR_LABEL_DUPL_IN_DEFINE 21
|
||||
|
||||
#define HB_PP_WARN_DEFINE_REDEF 1
|
||||
#define HB_PP_WARN_NO_DIRECTIVES 2
|
||||
|
||||
HB_EXTERN_END
|
||||
|
||||
#endif /* HB_PP_H_ */
|
||||
|
||||
@@ -341,7 +341,7 @@ static void pp_ParseBuffer( PFILE pFile, int *plLine )
|
||||
|
||||
if( *ptr == '#' )
|
||||
{
|
||||
BOOL bIgnore = hb_pp_ParseDirective( ptr );
|
||||
BOOL bIgnore = hb_pp_ParseDirective_( ptr );
|
||||
|
||||
if( pFile != hb_comp_files.pLast )
|
||||
{
|
||||
@@ -604,7 +604,7 @@ int hb_pp_ReadRules( void )
|
||||
|
||||
if( *ptr == '#' )
|
||||
{
|
||||
hb_pp_ParseDirective( ptr );
|
||||
hb_pp_ParseDirective_( ptr );
|
||||
}
|
||||
|
||||
*s_szLine = '\0';
|
||||
4813
harbour/utils/hbpp/ppcore.c
Normal file
4813
harbour/utils/hbpp/ppcore.c
Normal file
File diff suppressed because it is too large
Load Diff
265
harbour/utils/hbpp/pplib.c
Normal file
265
harbour/utils/hbpp/pplib.c
Normal file
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Preprocessor runtime library callable version
|
||||
*
|
||||
* Copyright 1999 Felipe G. Coury <fcoury@creation.com.br>
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Avoid tracing in preprocessor/compiler.
|
||||
*/
|
||||
#if ! defined(HB_TRACE_UTILS)
|
||||
#if defined(HB_TRACE_LEVEL)
|
||||
#undef HB_TRACE_LEVEL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
/* #include <setjmp.h> */
|
||||
|
||||
#include "hbpp.h"
|
||||
#include "hbcomp.h"
|
||||
#include "hbapi.h"
|
||||
#include "hbapierr.h"
|
||||
|
||||
#ifdef HB_EXTENSION
|
||||
|
||||
HB_PATHNAMES * hb_comp_pIncludePath = NULL;
|
||||
PHB_FNAME hb_comp_pFileName = NULL;
|
||||
FILES hb_comp_files;
|
||||
int hb_comp_iLine; /* currently parsed file line number */
|
||||
int hb_comp_iLinePRG;
|
||||
int hb_comp_iLineINLINE = 0;
|
||||
|
||||
/* These are need for the PP #pragma support */
|
||||
BOOL hb_comp_bPPO = FALSE; /* flag indicating, is ppo output needed */
|
||||
BOOL hb_comp_bStartProc = TRUE; /* holds if we need to create the starting procedure */
|
||||
BOOL hb_comp_bLineNumbers = TRUE; /* holds if we need pcodes with line numbers */
|
||||
|
||||
#if 0
|
||||
BOOL hb_comp_bShortCuts = TRUE; /* .and. & .or. expressions shortcuts */
|
||||
#endif
|
||||
|
||||
int hb_comp_iWarnings = 0; /* enable parse warnings */
|
||||
BOOL hb_comp_bAutoMemvarAssume = FALSE; /* holds if undeclared variables are automatically assumed MEMVAR (-a)*/
|
||||
BOOL hb_comp_bForceMemvars = FALSE; /* holds if memvars are assumed when accesing undeclared variable (-v)*/
|
||||
BOOL hb_comp_bDebugInfo = FALSE; /* holds if generate debugger required info */
|
||||
int hb_comp_iExitLevel = HB_EXITLEVEL_DEFAULT; /* holds if there was any warning during the compilation process */
|
||||
FILE * hb_comp_yyppo = NULL;
|
||||
|
||||
/* static jmp_buf s_env; */
|
||||
|
||||
HB_FUNC( __PP_INIT )
|
||||
{
|
||||
hb_pp_Table();
|
||||
hb_pp_Init();
|
||||
hb_comp_files.iFiles = 0;
|
||||
|
||||
if( ISCHAR( 1 ) )
|
||||
{
|
||||
hb_fsAddSearchPath( hb_parc( 1 ), &hb_comp_pIncludePath );
|
||||
}
|
||||
}
|
||||
|
||||
HB_FUNC( __PP_PATH )
|
||||
{
|
||||
if( ISLOG( 2 ) && hb_parl( 2 ) && hb_comp_pIncludePath )
|
||||
{
|
||||
hb_fsFreeSearchPath( hb_comp_pIncludePath );
|
||||
hb_comp_pIncludePath = NULL;
|
||||
}
|
||||
|
||||
if( ISCHAR( 1 ) )
|
||||
{
|
||||
hb_fsAddSearchPath( hb_parc( 1 ), &hb_comp_pIncludePath );
|
||||
}
|
||||
}
|
||||
|
||||
HB_FUNC( __PP_FREE )
|
||||
{
|
||||
if( hb_comp_pIncludePath )
|
||||
{
|
||||
hb_fsFreeSearchPath( hb_comp_pIncludePath );
|
||||
hb_comp_pIncludePath = NULL;
|
||||
}
|
||||
|
||||
hb_pp_Free();
|
||||
|
||||
if( hb_pp_aCondCompile )
|
||||
{
|
||||
hb_xfree( hb_pp_aCondCompile );
|
||||
hb_pp_aCondCompile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
HB_FUNC( __PPADDRULE )
|
||||
{
|
||||
if( ISCHAR( 1 ) )
|
||||
{
|
||||
char * ptr = hb_parc( 1 );
|
||||
char * hb_buffer;
|
||||
|
||||
HB_SKIPTABSPACES( ptr );
|
||||
if( *ptr == '#' )
|
||||
{
|
||||
if( !hb_pp_aCondCompile )
|
||||
{
|
||||
hb_pp_Table();
|
||||
hb_pp_Init();
|
||||
hb_comp_files.iFiles = 0;
|
||||
}
|
||||
hb_pp_ParseDirective( ptr );
|
||||
if( hb_comp_files.pLast )
|
||||
{
|
||||
hb_buffer = ( char* ) hb_xgrab( HB_PP_STR_SIZE );
|
||||
while( hb_pp_Internal( NULL, hb_buffer ) > 0 );
|
||||
hb_pp_CloseInclude();
|
||||
hb_xfree( hb_buffer );
|
||||
}
|
||||
hb_retl( 1 );
|
||||
}
|
||||
else
|
||||
hb_retl( 0 );
|
||||
}
|
||||
else
|
||||
hb_retl( 0 );
|
||||
}
|
||||
|
||||
HB_FUNC( __PREPROCESS )
|
||||
{
|
||||
if( ISCHAR( 1 ) )
|
||||
{
|
||||
char * pText = ( char * ) hb_xgrab( HB_PP_STR_SIZE );
|
||||
char * pOut = ( char * ) hb_xgrab( HB_PP_STR_SIZE );
|
||||
|
||||
/* if( setjmp( s_env ) == 0 ) */
|
||||
{
|
||||
char * ptr = pText;
|
||||
int slen;
|
||||
|
||||
/* hb_pp_Init(); */
|
||||
|
||||
slen = HB_MIN( hb_parclen( 1 ), HB_PP_STR_SIZE - 1 );
|
||||
memcpy( pText, hb_parc( 1 ), slen );
|
||||
pText[ slen ] = 0; /* Preprocessor expects null-terminated string */
|
||||
if( slen )
|
||||
{
|
||||
memset( pOut, 0, HB_PP_STR_SIZE );
|
||||
|
||||
HB_SKIPTABSPACES( ptr );
|
||||
|
||||
if( !hb_pp_topDefine )
|
||||
hb_pp_Table();
|
||||
if( *ptr && hb_pp_ParseExpression( ptr, pOut, FALSE ) > 0 )
|
||||
{
|
||||
/* Some error here? */
|
||||
}
|
||||
}
|
||||
hb_retc( pText ); /* Preprocessor returns parsed line in input buffer */
|
||||
}
|
||||
/* else
|
||||
{ */
|
||||
/* an error occured during parsing.
|
||||
* The longjmp was used in GenError()
|
||||
*/
|
||||
/* hb_retc( NULL );
|
||||
} */
|
||||
|
||||
hb_xfree( pText );
|
||||
hb_xfree( pOut );
|
||||
}
|
||||
else
|
||||
hb_retc( NULL );
|
||||
}
|
||||
|
||||
void hb_compGenError( char * szErrors[], char cPrefix, int iError, const char * szError1, const char * szError2 )
|
||||
{
|
||||
PHB_ITEM pError;
|
||||
char buffer[ 128 ];
|
||||
|
||||
HB_SYMBOL_UNUSED( cPrefix );
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_compGenError(%p, %c, %d, %s, %s)", szErrors, cPrefix, iError, szError1, szError2));
|
||||
|
||||
/* TOFIX: The internal buffers allocated by the preprocessor should be
|
||||
deallocated here */
|
||||
|
||||
sprintf( buffer, szErrors[ iError - 1 ], szError1, szError2 );
|
||||
pError = hb_errRT_New( ES_ERROR, "PP", 9999, ( ULONG ) iError, buffer, NULL, 0, EF_NONE | EF_CANDEFAULT );
|
||||
hb_errLaunch( pError );
|
||||
hb_errRelease( pError );
|
||||
|
||||
/* longjmp( s_env, iError == 0 ? -1 : iError ); */
|
||||
}
|
||||
|
||||
void hb_compGenWarning( char * szWarnings[], char cPrefix, int iWarning, const char * szWarning1, const char * szWarning2 )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_compGenWarning(%p, %c, %d, %s, %s)", szWarnings, cPrefix, iWarning, szWarning1, szWarning2));
|
||||
|
||||
/* NOTE: All warnings are simply ignored */
|
||||
|
||||
HB_SYMBOL_UNUSED( szWarnings );
|
||||
HB_SYMBOL_UNUSED( cPrefix );
|
||||
HB_SYMBOL_UNUSED( iWarning );
|
||||
HB_SYMBOL_UNUSED( szWarning1 );
|
||||
HB_SYMBOL_UNUSED( szWarning2 );
|
||||
}
|
||||
|
||||
PINLINE hb_compInlineAdd( char * szFunName )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( szFunName );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void hb_compParserStop( void )
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
#xtranslate HB_OSNewLine() => ( Chr( 13 ) + Chr( 10 ) )
|
||||
#endif
|
||||
|
||||
#command TEXT TO VAR <v> => #pragma __stream|%s||<v>:=
|
||||
#command CTEXT TO VAR <v> => #pragma __cstream|%s||<v>:=
|
||||
#command XTEXT TO VAR <v> => #pragma __text|<v>+=%s+HB_OSNEWLINE()||<v>:=""
|
||||
/* #command TEXT TO VAR <v> => #pragma __stream|<v>:=%s */
|
||||
#command TEXT TO VAR <v> => #pragma __text|<v>+=%s;<v>:=""
|
||||
#command CTEXT TO VAR <v> => #pragma __cstream|<v>:=%s
|
||||
#command XTEXT TO VAR <v> => #pragma __text|<v>+=%s+HB_OSNEWLINE();<v>:=""
|
||||
|
||||
/* Testing preprocessor */
|
||||
|
||||
@@ -18,7 +19,7 @@ LOCAL nCnt:=0
|
||||
LOCAL nRes:=0
|
||||
|
||||
/* ---------------------------------------------------------------------*/
|
||||
in := "#xtranslate CCC <v> => QOUT( <v>[2] [, <v>[<v>][3]] )"+HB_OSNewLine()+;
|
||||
in := "#xtranslate CCC <v> => QOUT( <v>[2] [, <v>\[<v>\]\[3\]] )"+HB_OSNewLine()+;
|
||||
"CCC b"
|
||||
pre := "QOUT(b[2] ,bb[3] )"
|
||||
nRes += PreResult( pre, PreRun( in, pre ), @nCnt )
|
||||
@@ -43,7 +44,7 @@ LOCAL nRes:=0
|
||||
/*------------*/
|
||||
XTEXT TO VAR in
|
||||
#define RED {255,0,0}
|
||||
#xcommand SET TOOLTIP TO <color> OF <form> => SM( TTH (<"form">), 1, RGB(<color>[1], <color>\[2\], <color>[, <color>[ 3 ] ]), 0)
|
||||
#xcommand SET TOOLTIP TO <color> OF <form> => SM( TTH (<"form">), 1, RGB(<color>\[1], <color>\[2\], <color>[, <color>\[ 3 \] ]), 0)
|
||||
SET TOOLTIP TO RED OF form1
|
||||
ENDTEXT
|
||||
TEXT TO VAR pre
|
||||
@@ -52,7 +53,7 @@ ENDTEXT
|
||||
nRes += PreResult( pre, PreRun( in, pre ), @nCnt )
|
||||
|
||||
/*------------*/
|
||||
in :="#command ZZZ [<v>] => QOUT([<v>[1]])"
|
||||
in :="#command ZZZ [<v>] => QOUT([<v>\[1\]])"
|
||||
__PreProcess( in )
|
||||
in :="ZZZ a"
|
||||
pre :="QOUT(a[1] )"
|
||||
@@ -1233,6 +1234,7 @@ FUNCTION PreResult( pre, out, pCnt )
|
||||
LOCAL i
|
||||
|
||||
pCnt++
|
||||
pre:=strtran(pre," "); out:=strtran(out," ")
|
||||
IF( pre == out )
|
||||
RETURN 1
|
||||
ELSE
|
||||
|
||||
Reference in New Issue
Block a user