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 / General / July 2005

Tip: Looking for answers? Try searching our database.

macro processor, string juggler, script language ?

Thread view: 
Harald - 28 Jul 2005 22:41 GMT
Doing a lot with regular expressions --- big ones, huge ones, terrifying
monster ones --- I end up piecing together things with static final
Strings. To give you an idea of how this may look:

 ...
 // Now piece it all together
 public static final String REALLY_CUTE_STUFF =
   "(" + WOOW + "[aeiou]*"
     + "|"  JUNK
     + "|"  BONGO
   ")*" + OPTSPACE

Obviously this is not easy to read, in particular on the third page of
code and with nested stuff all along.

o) I thought about using a script language (jython, jacl come to mind) and
its string manipulation facilities in external scripts to generate the
regexps. But this separates the regexps from the code and the two get
out of sync all to easy.

o) I thought about using jython or jacl interpreter objects to
interpret scripts in static final Strings, but this would entail,
say, python code within the Java source code, which isn't nice either.

o) I thought about piecing together a macro expansion facility
myself. Easy enough, but there are so many wheels around, I should not
have to invent another one.

Suggestions?

 Harald.

Signature

---------------------+---------------------------------------------
Harald Kirsch (@home)|
Java Text Crunching: http://www.ebi.ac.uk/Rebholz-srv/whatizit/software

Thomas Weidenfeller - 29 Jul 2005 08:20 GMT
> o) I thought about using a script language (jython, jacl come to mind) and
> its string manipulation facilities in external scripts to generate the
> regexps. But this separates the regexps from the code and the two get
> out of sync all to easy.

That's when a good build system comes into play. You just declare that
your code X.java depends on X.your-input-to-the-generator and if
X.your-input-to-the-generator got changed than X.java should be regenerated.

> [...]

> o) I thought about piecing together a macro expansion facility
> myself. Easy enough, but there are so many wheels around, I should not
> have to invent another one.

That's not much different from your first idea. Whether you generate
code with a code generator or with a macro-preprocessor, you still need
to keep the generated output in sync. with the input.

BTW, I would not spend any time building an own macro preprocessor.
Instead, I would use one of the existing ones, e.g. good old M4. My
choice of a scripting language (your first idea), would also be among
the more traditional ones like perl, awk, sed.

/Thomas

Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/



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.