Schliemannizing Regular Expressions in NetBeans IDE

I've been trying to find tokens to exercise my newly acquired Schliemann skills on. Eventually, after investigating a variety of interesting scripting languages (including one called MUMPs, which would have made a cool subject line for a blog entry: "Schliemann Has Mumps"), I settled on regular expressions, because NetBeans engineer Martin Adamek has a regular expression tester on (Sandip has a regular expression checker there too). In other words, the tokens already exist. (Do you have tokens? Do they need language support features? Please send them along to me and I'll take good care of them...)

So basically, this is as much a porting guide as instructions for creating syntax colors (and more stuff in the future) for regular expressions. Although, if all you're doing is taking tokens from an existing module, and rewriting them the Schliemann way (i.e., regular expressions), then you're not really porting. So little of the original code can be reused, because you need so little code for Schliemann in the first place.

Interestingly, here we're using Schliemann within a JEditorPane, instead of in the NetBeans editor. That's also totally possible, simply by putting the MIME type in the contentType property of the JEditorPane. So, this is what I did:

  1. Set up the module. Create a MIME resolver and NBS file, wizards are available for both. Register the two files in the XML layer. Assign the MIME type to the JEditorPane contentType, in the GUI Builder's Properties window. Install the module.

    Usefully, because nothing you type matches a token (because you have not defined tokens yet), the entire line/s that you enter in the JEditorPane is/are displayed in red, as shown below:

    If part of the line were recognized as a token, that part would not be red, as we shall see later.

  2. Copy your tokens from To understand what the tokens are supposed to represent, see

    As you define your tokens, keep on checking your progress, by installing the module again and seeing how much of your code is captured by the token definitions. Here you can see we've made some progress already:

Not quite done yet, clearly, but getting there. And all it took was that I defined the following tokens and colors, partly based on Martin Adamek's regular expression tester on

TOKEN:string:( "\\'" )
TOKEN:identifier:( ["a"-"z"] ["a"-"z" "0"-"9"]\* )
TOKEN:operator:( "-" | "+" | "\*" | "!" | "=" | "," | ";" ) 
TOKEN:bracket:( "(" | ")" | "<" | ">" | "[" | "]" )
TOKEN:dot:( "." )

COLOR:identifier: {
    foreground_color: "blue";
COLOR:operator: {
    foreground_color: "blue";
COLOR:bracket: {
    foreground_color: "red";
    font_type: "bold";
COLOR:dot: {
    foreground_color: "black";
    font_type: "bold";
COLOR:string: {
    foreground_color: "magenta";
    font_type: "bold";

Now I basically have the basis for further support for regular expressions, such as a navigator and other cool language features. Tools for regular expressions are going to become pretty important in 6.0, I reckon, because so much of Schliemann depends on working with regular expressions. So, the modules by Martin and Sandip (or derivatives of these) in this area are going to be helpful to have around.

By the way, thanks especially to Alex Kotchnev (plus a few others, such as Jochen from the Groovy mailing list), I now have a full blown functioning Groovy Console integrated in NetBeans IDE (plus, including the menu bar). Thanks to the NetBeans windowing system, I can even have two consoles (or as many as my heart desires) open at the same time:

Hurray for Groovy. Next, I'm going to try and do something with the Groovy Compiler. Or are there other things that should be looked at more urgently, either in relation to Groovy or in relation to Grails?

In other news. "Schliemannizing" is a brand new word. It means: "to radically simplify the implementation of, while extensively improving, something", as in the sentence: "He Schliemannized his NetBeans module, and now there are only two files left, instead of 200, while at the same time 10 new features have been added." When the word starts being used everywhere, from the depths of your local pub ("they Schliemannized my favorite beer, so now I get a hangover after just a single drop"), to the middle of a Larry King interview ("has your life improved now that your breasts have been Schliemannized?") , to the high point of the Queen's Christmas speech ("we will do all we can to Schliemannize our next Christmas speech, but chances are that it will be equally dull and at least three times as long"), remember... you heard it here first.


One thing that I was considering is making Groovy Console run in the context of a particular Java project (e.g. making the classpath of the project available in the console). Often times, when I need to test something out, I'd fire up the console inside of NetBeans, then add a few jars (which are already described in the project) to the classpath, and then messing around with the objects in the project. I know that Grails has something like that (where basically, you fire up a console and you are in the context of the Grails project and can manipulate the objects). Currently, in order to do this, I'd create a Groovy project (using Coyote), add all dependencies of the original project, and then use the Groovy script to fire up the Groovy console . Now that I'm thinking about it.. too much work for such a common task :-) Btw, are you going to make a project for the Groovy/Grails integration somewhere so that we can start trickling some goodies into it ?

Posted by Alex Kotchnev on March 20, 2007 at 05:48 AM PDT #

How about giving Jython (Python) a try?

Posted by Sven Reimers on March 20, 2007 at 06:41 AM PDT #

Has Schliemann been Schliemannized? ;-)

Posted by Hugues Ferland on March 20, 2007 at 10:50 AM PDT #

I think code completion and refactoring for Groovy would be awesome. although I know this is hard to do. Matisse being able to produde Groovy code instead of Java would be awesome too. if, one day, Groovy support in Netbeans is as great as Java support, Groovy will really take off. the language is great. Grails too. the only thing that that is lacking is a really powerful IDE

Posted by Claus Burger on March 20, 2007 at 04:55 PM PDT #

Hi Alex, thanks for your thoughts, I will think about them. Yes, I plan to make a project for this. Not sure what to call it. Ideas? Maybe "Coyote 2" or maybe something totally different.

Hi Sven, Sandip has something on Jython. Sandip, will you blog about it???

Hi Hugues. Yes! Se here, Schliemann is done in the Schliemann way.

Hi Claus, I'm looking into all of the things you mention. Not sure if it is possible, but would be cool if Matisse could be used to write Groovy, since Groovy also does Swing. Investigating, watch this space.

Posted by Geertjan on March 20, 2007 at 11:08 PM PDT #

Can you please let me know where can i get some examples of the use of regular expressions using C++ in Netbeans (Ubuntu 7.10)

Posted by John on October 07, 2008 at 11:18 AM PDT #

John, please ask your question at

Posted by Geertjan on October 07, 2008 at 12:07 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« April 2014