Presents your JAVA E-NEWSLETTER for August 14, 2003 <-------------------------------------------> CREATE MINI-LANGUAGES USING ANTLR In the life of a complicated system, it may become crucial at some point to change the system's behavior without recompiling and redeploying it. You can achieve this functionality by creating a domain or mini-language specifically for manipulating system components. (Domain languages are small languages that allow an application's programmer or administrator to change how components interact with each other, and even to decide what components will exist when the system is running.) After you decide that you need a domain language, you'll have to design its syntax; this means determining the language's capabilities and what it will look like. Once you've decided on the language's syntax, the next step is to create a parser for the language, which can be quite a large, arduous task. If you've ever built a parser by hand, then you know that the complexity of the parser grows exponentially in relation to the complexity of the language. One of the tools at your disposal is ANTLR (ANother Tool for Language Recognition), which allows you to describe your language in a text file. If you point ANTLR at this file, it will generate a Lexer and a Parser that are capable of processing your new language. A Lexer translates characters into language tokens, and a Parser uses these tokens to perform work. Once ANTLR has generated these classes for your mini-language, you can use them in your applications to manipulate your system. Even with the help of ANTLR, creating your first mini-language can be quite complicated and require a lot of work. The good news is that the folks who maintain ANTLR provide a number of resources to get you started. Visit ANTLR's site and take a look for yourself. http://ct.com.com/click?q=94-rOTNQaIYkZMFbBqW9PRW8W990Qz2 David Petersheim is a Senior Java Developer with Genscape, Inc. He designs and develops server-side applications to acquire and process real-time energy data. JAVA FORUM: SHARE YOUR EXPERTISE WITH THE COMMUNITY We've designated the Java Forum as the place where members can talk technique, argue methods, ask questions, and share experiences. Offer your views in the Java Forum or send us an e-mail. http://ct.com.com/click?q=a9-IlBqQpUmKeu6jrbBlktP5R7MkMN1 mailto:Enews2@cnet.com ----------------------------------------