tags:

views:

46

answers:

2

I have a simple web application testing desktop application. I am wondering how I can create my own scripting language for it (Domain Specific Language).

The purpose of this is to offer a very intuitive scripting even for non programmers, and able to define user scenario specific details.

I hope this is clear, basically the question is, how do I create a simple-to-use scripting language that can be translated into Java code.

Perhaps, they can use netbean's IDE to write the scripts.

For ex)

my script:

load "http://www.google.com";
click "Search" button;

java code:

browser.navigate("http://www.google.com";
browser.wait
browser.element("Search").click();
+1  A: 

The best solution would be to reuse one the existing scripting languages for Java; for example BeanShell. Implementing your own scripting language would be whole a lot of work. And if you've never done any language design and implementation work before the results are likely to be "less than stellar".

Perhaps, they can use netbean's IDE to write the scripts.

Expecting users of your application (especially non-programmers) to install and use a particular IDE sounds like a really bad idea.

... that can be translated into Java code.

Translating to Java code complicates things as well. It is probably better to interpret a scripting language and access Java APIs using a combination of staticly typed method calls and (only where necessary) the Java reflection APIs.

Stephen C
+2  A: 

The best tool/framework for languages which extend beyond very simple grammars is to use ANTLR. Its a full featured lexer+parser combination, great Java integration, and tons of examples with good documentation.

Do realize that this isn't a trivial project to get right. You should use an existing language if your time is limited

Yann Ramin