From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6458d1ee91b224ec X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 X-Received: by 10.180.106.161 with SMTP id gv1mr1888469wib.4.1360486918245; Sun, 10 Feb 2013 01:01:58 -0800 (PST) Path: g1ni791wig.0!nntp.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: =?UTF-8?B?QmrDtnJu?= Persson Newsgroups: comp.lang.ada Subject: Re: chopping Ada source that have preprocessor symbols in them Date: Sun, 10 Feb 2013 10:01:54 +0100 Message-ID: <20130210100154.7ef5a26b@hactar.xn--rombobjrn-67a.se> References: <5111a9d5$0$6567$9b4e6d93@newsspool3.arcor-online.net> Mime-Version: 1.0 X-Trace: individual.net jWfJE2CXM97Du61h6onGkgNHz3Hr05nZJeg2ovv9h7nIPVwTkTPjRaRdUBd/VoAK4V Cancel-Lock: sha1:TEW9if4QvozKjUoX0nOlSs+QBnY= X-Newsreader: Claws Mail 3.9.0 (GTK+ 2.24.13; x86_64-redhat-linux-gnu) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Date: 2013-02-10T10:01:54+01:00 List-Id: Georg Bauhaus wrote: > I need to integrate an Ada source program that consists > of a few compilation units. When I want one unit per file, > then, usually, I can call gnatchop and be done. >=20 > However, the program is using preprocessor symbols that > I wish to keep. gnatchop can parse source files using > different characters sets, but apparently it cannot parse > files that use preprocessor symbols, including GNAT ones. >=20 > My "solutions" are not solutions, I feel. Either >=20 > - I call gnatprep with the original program as input and use > the output as input to gnatchop. I loose the preprocessor > symbols in all resulting compilation units, >=20 > or >=20 > - I do manual labor. >=20 > Neither is working well, really. Are there other options? I take it you need to keep the original source file up to date and chop it repeatedly, otherwise you would have simply done the manual labor by now. Perhaps you could do a reversible transformation of the file to make the preprocessor symbols look like Ada identifiers that Gnatchop will accept? Something like this: #!/bin/sh sed 's/\$/My_Special_Dollar_Replacement/g' a_file.ada.gp >a_file.munged gnatchop -w a_file.munged sed -i s/My_Special_Dollar_Replacement/$/g *.ad? Or replace the last line with a loop if your Sed doesn't support in-place editing. While this hack is certainly possible to break I think it should work well enough in practice. I think I would prefer to use source reference pragmas and do my editing in the actual source file though, unless the compilation time is really prohibitive even with minimal recompilation. Bj=C3=B6rn Persson