I've designed a very simple domain specific language(DSL) to specify and execute full-screen interactive behavior on devices. It's event based action language with XML as the carrier syntax. Example of it is here:
<state no="15000" >
<timeout>30</timeout>
<backgroundactions>
<as3function name="hideImages">
</as3function>
</backgroundactions>
<screen>
<components>
<textfield x="50" y="120" width="924" textsize="50" background="1" border="1">
<text say="1">
<part type="text">Who would you like to call?</part>
</text>
</textfield>
<button label="MENU" width="80" height="30" x="920" y="10" textsize="14" icon="none" adjtext="-5">
<event name="clicked">
<action preconditions="no" name="transition">
<parameter>
<type>state</type>
<name>n</name>
<value>800</value>
</parameter>
</action>
</event>
</button>
<button label="My contacts" width="250" height="200" x="212" y="500" textsize="40" icon="iconRight2.png" iconx="65" icony="20" adjtext="35">
<event name="clicked">
<action preconditions="no" name="transition">
<parameter>
<type>state</type>
<name>n</name>
<value>15007</value>
</parameter>
</action>
</event>
</button>
<button label="Other" width="250" height="200" x="562" y="500" textsize="40" icon="iconWrong2.png" iconx="65" icony="20" adjtext="35">
<event name="clicked">
<action preconditions="no" name="transition">
<parameter>
<type>state</type>
<name>n</name>
<value>15100</value>
</parameter>
</action>
</event>
</button>
</components>
</screen>
</state>
It semantically means the following:
It's a state transition language where the programmer declaratively describes the UI layout and the events to which the program should react to and the actions flowing the events. The DSL is designed for readability. Here's a short description of the nodes:
Is there a way to represent this particular language in a more formal description as a grammar or meta-model(i am not familiar with language modeling techniques). My idea is to write a language specifications for this DSL so that other programmers in my team can generate scripts in other languages of their choice such as python or lua from this specifications. Possibly even code-generate this XML as well? What would be the best way to represent this? I have been going through lots of language tools and dsl tools, but i can't figure out what would be most efficient for this langauge? someone with expertise can help me in the right direction and give a headstart on the steps that need to be done.
Use of DSLs to get close to the actual problem domain (UI and related events) makes perfectly sense. I’m aware of several metamodels specified for a certain UI, such as: mobile phones, sports computers, automotive infotainment systems, various touchscreen devices and web apps (see some public languages at http://www.metacase.com/cases/dsm_examples-ui.html). The generators can then be used to produce actual code, prototypes or test scripts.
To define these domain-specific modeling languages you specify first the metamodel including concepts (e.g. button, transition, state) and related rules (e.g. pressing button triggers a transition) followed by some notation. Then you can test the language to define a sample models like you did with the XML, and finally having some models ready, you can define the generators producing the expected results. With this appraoch companies like Panasonic, Polar and EADS have reported about better quality and increase speed. I’ve been personally involved is several such cases providing assistance, and wrote an article on the language definition at http://www.devx.com/enterprise/Article/30550. Hope this helps.