Re: defines in 4gl
Posted in 1993
To the 4gl macro searcher 19 Jun 1993 Subject: Re: #defines in 4gl ---------------------------- I have an very old dirty solution to this subject - I made it years ago. As far as I know, a lot of different solutions exist and it must be possible for you to find one, which can do the job. If you can use this one then just go ahead - Change it if you like or you may dump it to /dev/null. Extract the shar files and run: imac SrcFile SrcFile is your macro 4gl sourcefile (with your #define statements and all that stuf) without its extensions .4ma Regards to you from ----------------------------------------------------------------- Databaseadministrator Poul Pedersen Kuwait Petroleum (Danmark) A/S Hummeltoftevej 49 Mail: pp@q8.dk 2830 Virum Voice: +45 45 98 45 94 Denmark Fax: +45 42 85 14 18 ----------------------------------------------------------------- ----- Cut -------------------------------------------------------------------- : "@(#)shar.sh 1.4" #! /bin/sh # # This is a shell archive. # Remove everything above this line and run sh on the resulting file. # If this archive is complete, you will see this message at the end: # "All files extracted" # # Created: Sat Jun 19 16:29:30 DST 1993 by pp at Kpd (Kuwait Petroleum Denmark). # Files archived in this archive: # imac # infcln.l # inflex.l # makefile # #-------------------- if [ -f imac -a imac != -c ] then echo shar: imac already exists else echo 'x - imac (938 characters)' sed -e 's/^X//' >imac <<'SHAR-EOF' X#! /bin/sh X#****************************************************************************** X#****************************************************************************** X#** X#** imac Informix-4gl macro precompiler, which implements X#** C-style macro definitions in Informix-4gl. X#** X#** The source file must have the extensions .4ma X#** X#** Activate this program by: X#** X#** imac source X#** X#** where source is source.4ma X#** output will be source.4gl X#** and there will be a workfile source.4cc X#** X#****************************************************************************** X#****************************************************************************** Xif [ ! -f $1.4ma ] ; then X echo "No macro source file: $1.4ma" X exit 1 Xfi Xif [ ! -f inflex ] ; then X make inflex Xfi Xif [ ! -f infcln ] ; then X make infcln Xfi Xinflex < $1.4ma > $1.4cc Xcc -EP $2 $3 $4 $5 $6 $7 $8 $9 $1.4cc > $1.4cl Xinfcln < $1.4cl > $1.4gl SHAR-EOF chmod 755 imac if [ `wc -c <imac` -ne 938 ] then echo shar: imac unpacked with wrong size fi # end of overwriting check fi #-------------------- if [ -f infcln.l -a imac != -c ] then echo shar: infcln.l already exists else echo 'x - infcln.l (1816 characters)' sed -e 's/^X//' >infcln.l <<'SHAR-EOF' X%{ X/****************************************************************************** X******************************************************************************* X** X** infcln.l This program was created by Poul Pedersen X** the 5-april-1990. X** X** This is a lex input source file for the lex program. X** The resulting program will recognice tokens. X** Informix-4gl comments which starts with {# and ends X** whith a }\\n, will be changed to # an \\n. X** X** To compile this lex source type: X** X** lex -t lexcln.l | sed -e "s/debug = 0;/debug = 1;/" > lexcln.c X** cc -o lexcln -DLEXDEBUG lexcln.c -ll X** X** If you want to debug you must change the X** substitute command, so that debug = 1. X** X** To activate the program type: X** X** lexcln < source X** X******************************************************************************* X******************************************************************************* X*/ X%} X%% X'[^']* | X\\"[^"]* { /* Pass all strings. X */ X if (yytext[yyleng-1] == '\\\\') X yymore(); X else { X yytext[yyleng++] = input(); X yytext[yyleng++] = NULL; X printf("%s", yytext); X } X } X"{#" { /* Skip { and } arround 4gl comment, X */ X while (yytext[yyleng-1] != '\\n') X yytext[yyleng++] = input(); X unput(yytext[yyleng-1]); X yyleng--; X yyleng--; X yytext[yyleng++] = NULL; X printf("%s", yytext+1); X } XNEW_LINE_4GL { /* Insert newline X */ X printf("\\n"); X } X[^ "#\\t\\n] { /* copy words X */ X while (yytext[yyleng-1] != '\\n' && X yytext[yyleng-1] != '\\t' && X yytext[yyleng-1] != ' ') X yytext[yyleng++] = input(); X unput(yytext[yyleng-1]); X yyleng--; X yytext[yyleng++] = NULL; X printf("%s", yytext); X } X\\t | X\\n | X" " { /* Copy tabs, spaces and newlines. X */ X printf("%s", yytext); X } SHAR-EOF chmod 644 infcln.l if [ `wc -c <infcln.l` -ne 1816 ] then echo shar: infcln.l unpacked with wrong size fi # end of overwriting check fi #-------------------- if [ -f inflex.l -a imac != -c ] then echo shar: inflex.l already exists else echo 'x - inflex.l (2313 characters)' sed -e 's/^X//' >inflex.l <<'SHAR-EOF' X%{ X/****************************************************************************** X******************************************************************************* X** X** inflex.l This program was created by Poul Pedersen X** the 5-april-1990. X** X** This is a lex input source file for the lex program. X** The resulting program will recognice tokens. X** Strings enclosed with "" or ''. X** Informix-4gl comments which starts with # and ends X** whith a \\n. X** C-style compiler directives like #define. X** Simple words, tabs, spaces and newlines are recogniced X** too. X** X** To compile this lex source type: X** X** lex -t lexsrc.l | sed -e "s/debug = 0;/debug = 1;/" > lexsrc.c X** cc -o lexprog -DLEXDEBUG lexsrc.c -ll X** X** If you want to debug you must change the X** substitute command, so that debug = 1. X** X** To activate the program type: X** X** lexprog < source.4gl X** X******************************************************************************* X******************************************************************************* X*/ X%} X%% X'[^']* | X\\"[^"]* { /* Pass all strings. X */ X if (yytext[yyleng-1] == '\\\\') X yymore(); X else { X yytext[yyleng++] = input(); X yytext[yyleng++] = NULL; X printf("%s", yytext); X } X } X#[ \\t]*if | X#[ \\t]*ifdef | X#[ \\t]*ifndef | X#[ \\t]*else | X#[ \\t]*endif | X#[ \\t]*define | X#[ \\t]*line | X#[ \\t]*include { /* Copy all compiler directives X ** to output. X