ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolas Lalevée <nicolas.lale...@hibnet.org>
Subject A DSL for Ant
Date Tue, 29 May 2012 12:26:35 GMT
Hi,

I was always been amazed by the features of the Xtext Eclipse plugin [1], so I played a little
bit with it and tried to make a DSL for Ant. And by DSL, I mean a real domain specific language
which is not a work around existing language like groovy front [2]. Now that I have been able
to make it work properly and I am quite happy of the result, I'm sharing it with you [3].
See the doc [4] for a screenshot of the plugin and an simple example of what a build.ant would
look like. The grammar definition is to be found there [5].

Far from everything as been implemented. But it is a nice proof of concept I think.
You may noticed I have introduce a if-then-else structure. I quite tired of doing workaround
in build.xml files :)
I tried to make macrodef look like a function definition, I am not sure it look nice.
I also tried to make the property task look like usual assignment. Maybe we could also do
references by adding a keyword in front, like: ref myref = "foo"

Let me know what you think of the grammar !

For those of you who look closely to the code, you should find two parsers. The first one
is the one generated by Xtext. But for the little experiment I have done, I found it very
slow to boot, more than 1s on my icore7, just the load the parser without having parsed anything
(there is some guice and ecore involved). Since the Xtext grammar is very very close to the
Antlr one (it is actually based on Antlr), I rewrote the AntDSL.xtext [5] into an AntDSL.g
[6]. And it is just as fast as anyone would expect, just the time to load some classes.
As having a generated Eclipse plugin is so awesome, and an AntDSL.g not that hard to duplicate,
I think I would make sense to have both.

Nicolas

[1] http://www.eclipse.org/Xtext/
[2] https://svn.apache.org/repos/asf/ant/sandbox/groovyfront
[3] https://svn.apache.org/repos/asf/ant/sandbox/antdsl
[4] https://svn.apache.org/repos/asf/ant/sandbox/antdsl/doc/index.html
[5] https://svn.apache.org/repos/asf/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDSL.xtext
[6] https://svn.apache.org/repos/asf/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AntDSL.g


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message