Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > macro processor, string juggler, script language ?

Reply
Thread Tools

macro processor, string juggler, script language ?

 
 
Harald
Guest
Posts: n/a
 
      07-28-2005

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.

--
---------------------+---------------------------------------------
Harald Kirsch (@home)|
Java Text Crunching: http://www.ebi.ac.uk/Rebholz-srv/whatizit/software
 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      07-29-2005
Harald wrote:
> 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

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

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python as active script <script language=python> misterdi Python 0 07-28-2009 04:30 PM
JSP problem: <script language="JavaScript"> '<%=expression%>' </script> Edward Java 1 04-03-2006 06:15 PM
in S.E. Asia : Canon EOS 300d with 100 macro ED vs. Nikon D70 with Nikon 105 macro ? J. Cod Digital Photography 0 09-29-2004 05:46 AM
#define macro to enclose an older macro with strings Dead RAM C++ 20 07-14-2004 10:58 AM
macro name from macro? D Senthil Kumar C Programming 1 09-21-2003 07:02 PM



Advertisments