Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / January 2004

Tip: Looking for answers? Try searching our database.

general purpose macro expander for Ant?

Thread view: 
bugbear - 26 Jan 2004 16:51 GMT
I've got a few DTD's in my program that have
extensive overlap.

Making sure that I edit them
"in sync" is tedious and error prone.

I'm also making extensive use of
parameter entities to make the DTD's compact
and easy to maintain.

Sadly, some XML tools don't react well
to parameter entities.

I'd like to use a macro preprocessor to resolve
both problems. I could use a simple #include
for the first issue, and simple #define for the
second one.

Ant's filtersets aren't powerful enough for what I need,
and m4 isn't Java (I would like my build process to remain
portable).

Is there a Java implemented macro processor?

     BugBear

P.S. Please note: this is NOT a request that the Java language
itself be pre-processed, a la CPP. I've seen the flame wars
that debate produced :-)
Robert Klemme - 27 Jan 2004 13:30 GMT
> I've got a few DTD's in my program that have
> extensive overlap.
[quoted text clipped - 25 lines]
> itself be pre-processed, a la CPP. I've seen the flame wars
> that debate produced :-)

Google has some hits for '"macro processor" "implemented in java"'
http://www.google.com/search?q=%22macro+processor%22+%22implemented+in+java%22

You'll find this
http://www.ugcs.caltech.edu/gema/

Maybe that's what you need.

Regards

   robert
bugbear - 28 Jan 2004 11:34 GMT
> Google has some hits for '"macro processor" "implemented in java"'
> http://www.google.com/search?q=%22macro+processor%22+%22implemented+in+java%22
[quoted text clipped - 5 lines]
>
> Regards

Thanks for the help. I found that one
(with a similar search to yours).

It's very sophisticated (not to mention unconventional).

Its pattern matching model is very powerful, but gema
doesn't appear to support #include type functionality.

I'll continue looking.

    BugBear
Michael Amling - 28 Jan 2004 16:12 GMT
>>Google has some hits for '"macro processor" "implemented in java"'
>>http://www.google.com/search?q=%22macro+processor%22+%22implemented+in+java%22
[quoted text clipped - 13 lines]
>
> I'll continue looking.

  You could exec() to gcc with the -E option, to have it do
preprocessing only. I tried the following and it worked for both
includes and for macro expansion.

  Process expanding=Runtime.getRuntime().exec(
   new String[]{"gcc", // program name
   "-E", // Preprocessing (includes and macro expansion) only
   "-P", // Do not generate '#line' commands.
   "-undef", // Do not predefine any nonstandard macros.
   "-o", "expandedoutputfile.xml", // Where to put result
   "-nostdinc", // Search only directories specified with -I
   "-Idirectorycontainingfilestobeincluded",
   "-Ianotherdirectorycontainingfilestobeincluded",
   "-x", "c", // Treat source file as .c regardless of its name
   "inputfile.xml"} // The source file to be expanded
   );

This would also get you conditional compilation.

--Mike Amling


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.