Archive

Archive for January, 2011

Antlr tutorial: Hello Antlr

January 27th, 2011 4 comments

Domain specific languages (DSL) are great tools to communicate with non-programmers. Normally this group includes business users that would like to configure a system / rule using a fluent language (as in – a natural language). It also includes those like my 8 year old neighbor that knows absolutely nothing about programming. He would love to tell the computer how to perform a small series of operations, without delving into the specifics. Coincidentally, I have been reading up on methodologies to approach DSLs and was introduced to ANTLR.

Enter ANTLR:

What my neighbor needs is an English like grammar. This grammar needs to be parsed into something meaningful at runtime. Every time the grammar changes, the parser would need to change too. ANTLR, is a ‘parser generator’. Once a grammar is defined, ANTLR can code-gen a lexer and a parser for this grammar. The lexer identifies tokens in any input that adheres to the grammar and the parser makes sense of these tokens.

Categories: java Tags: , , ,

CodePro overview

January 12th, 2011 No comments

Google recently donated a code profiling product to eclipse. A related code analytics product named CodePro is worth a look. It integrates with eclipse nicely. Lets take it for a test drive

Code Audit:

This tool allows you to check for obvious mistakes in your code. Think findbugs. You can add / edit rule sets and then run a code audit. At the end of the auditing process, the results display shortcomings in the code. If you already work with findbugs, there is nothing new to see here.

Code review:

Testing tools:

Ever spent time writing tons of junit code ? CodePro can help cut that short by writing codegen that will automatically test paths in your code. Take this class for example

Hello world

package com.test;
 
public class HelloWorld
{
 
    public static void main(String... args)
    {
        new HelloWorld().go(11);
    }
 
    public void go(int i)
    {
        System.out.println("Hello world");
        if(i==10)
        {
            throw new RuntimeException();
        }
        System.out.println(i);
    }
}
Categories: java Tags: , ,