🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #52295

how to use my own tcl-enhanced "GNU" cpp with gcc specs

#52295
From: Basile STARYNKEVITCH
Date: Sat, 28 Nov 1992 17:14
98 lines
4422 bytes
I have enhanced Gnu gcc 2.3.1 ccp to use Tcl code, by patching the
cccp.c file with some stuff (calling tcl-6.3).

Tcl is a publicly available interpreter and library, with a shell-like
syntax. the only tcl type is char-string, but tcl structures them with
[] () and {}. Tcl is written by John Ousterhout at Univ. Calif.
Berkeley: ouster@sprite.berkeley.edu.

My question is how to use gcc (either with -Boption, or GCC_EXEC_PREFIX env var...) to use my modified cpp instead of the gnu 2.3.1 cpp (i do want to leave
for some time the unmodified Gnu cpp for ordinary stuff).

I first describe my patch.

If passing the -tclmacro flag to my patched ccp, i can define
tclmacros, which, when expanded by the preprocessor, are calling some
tcl-interpreted stuff; a tclmacro is defined by #tcldef; all lines up
to #tclend are feed to the tcl interpreter as a tcl proc definition;
when expanding this tclmacro, the associated tcl proc is called (ie
Tcl_Eval-ed) with the cpp arguments. The result of this tcl-evaluation
is feed up again (rescanned) by my cpp.

I've decided to write (in less than 2 days! thanks to Gnu cpp and Tcl!)
this enhanced preprocessor, because i need to make some computation
while preprocessing and found m4 or cpp inadequate...

for instance, the input file eumproc.h write on stderr 
(as a result of puts stderr Tcl commands):

Debut de nom_procedure 

Corps de nom_procedure
Fin de nom_procedure


and produce output file as shown next 
####################fil eumproc.h shifted 4 chars ####################
   /*- file eum3/eumproc.h %W% %G% line %C% */
   #ifndef _EUMPROC_INCLUDED_
   #define _EUMPROC_INCLUDED_
   
   
   #ifndef __TCLMACROS__
   #error This file should be compiled on Basile cpp -tclmacros
   #endif __TCLMACROS__
   
   #tcldef EUM_BEGIN_PROC(ProcName)
     global EumProcs EumCurrentProc
     puts stderr "Debut de $ProcName \n"
     set EumProcs($ProcName) {}
     set EumCurrentProc ProcName
     return "void $ProcName (Eum_object _ctx)"
   #tclend /*EUM_BEGIN_PROC*/
   
   #tcldef EUM_END_PROC(ProcName)
     global EumCurrentBody
     puts stderr "Fin de $ProcName\n"
     return "$EumCurrentBody \} /*-- end $ProcName --*/\n"
   #tclend /* EUM_END_PROC */
   
   #tcldef EUM_BODY_PROC(ProcName,ProcBody)
     # braces are not needed
     global EumCurrentProc
     global EumCurrentBody
     puts stderr "Corps de $ProcName"
     set EumCurrentBody $ProcBody
     return "\{ /*body of $ProcName*/ "
   #tclend /*EUM_BODY_PROC*/
   
   #define EUM_PROC(Name,Body) EUM_BEGIN_PROC(Name) EUM_BODY_PROC(Name,Body) EUM_END_PROC(Name)
   
   EUM_PROC(nom_procedure, { corps_procedure; })
   
   
   #endif  /* _EUMPROC_INCLUDED_ */

#################end of file eumproc.h #######################

the output of my modified cpp is (i've manually deleted several blank lines)

# 1 "/netdisk/beltegeuse.1/basile/eum3/eumproc.h"


void nom_procedure (Eum_object _ctx) { /*body of nom_procedure*/   { corps_procedure; } } /*-- end nom_procedure --*/
 
# 36 "/netdisk/beltegeuse.1/basile/eum3/eumproc.h"

####
if some people are interested by my patches, i will post to
gnu.gcc.help or email to them. Please email me to ask for my patches.

-- 
Basile STARYNKEVITCH
Commissariat a l Energie Atomique
DRN/DMT/SERMA * C.E. Saclay bat.470 * 91191 GIF/YVETTE CEDEX * France
fax: (33) 1- 69.08.23.81;    phone: (33) 1- 69.08.40.66
email: basile@soleil.serma.cea.fr;  homephone: (33) 1- 46.65.45.53
N.B. Any opinions expressed here are solely mine, and not of my organization.
N.B. Les opinions exprimees ici me sont personnelles et n engagent pas le CEA.
Technical Details
Message-ID: <1992Nov28.171422.12431@nenufar.saclay.cea.fr>
Path: arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!julienas!nenufar.saclay.cea.fr!soleil!basile

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,95951baccb1c44b7,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1992-11-28 09:37:47 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!julienas!nenufar.saclay.cea.fr!soleil!basile
From: basile@soleil.serma.cea.fr (Basile STARYNKEVITCH)
Subject: how to use my own tcl-enhanced "GNU" cpp with gcc specs
Sender: @nenufar.saclay.cea.fr
Message-ID: <1992Nov28.171422.12431@nenufar.saclay.cea.fr>
Date: Sat, 28 Nov 1992 17:14:22 GMT
Reply-To: basile@soleil.serma.cea.fr (Basile STARYNKEVITCH)
Nntp-Posting-Host: soleil-gw.serma.cea.fr
Organization: Commissariat a l Energie Atomique
Lines: 98