generic language technology - tu/elengelen/gltooti2011/case_study.pdf · generic language...

3
Generic Language Technology Case Study Introduction This case study is meant to get you acquainted with domain-specific languages (DSLs) and model-driven software engineering (MDSE). You will apply MDSE by generating code written in the language Not Exactly C (NXC) based on models specified using a simple DSL. First, you are asked to construct two DSLs: one that describes a path by listing a number of coordinates on that path, and one that describes a path by listing commands that would direct a vehicle along this path. The second DSL serves as an intermediate language between the first DSL and NXT code. After defining these DSLs, you are asked to implement a transformation that takes a list of coordinates as input and produces a list of commands that describes the same path. The last step of the case study is implementing two templates that can be used to generate code from models specified using the two DSLs. One template should take a list of coordinates and produce an NXT program that displays the path on the display of the NXT. The other template should take a list of movements and produce an NXT program that directs a vehicle along the path specified by the movements. Getting Started For this case study, you need to study a Lego vehicle, install and use software to program the programmable Lego NXT brick, and install and use various Eclipse-based tools. The small Lego vehicle that is used for this case study is described on pages 5 to 15 of the Lego Mindstorms NXT manual. The manual is available online (http://mindstorms.lego.com/en-us/support/buildinginstructions/8547/ 8547UserGuideEnglish.aspx). The programmable Lego NXT brick should be programmed using NXC. Doc- umentation concerning NXC is available online (http://bricxcc.sourceforge. net/nbc/nxcdoc/). The Bricx Command Center can be used to compile NXC programs and transfer them to the NXT brick. It can be downloaded from http://bricxcc. sourceforge.net/. We have prepared a number of tutorial assignments that should help you get acquainted with the Eclipse-based tools. These assignments and their solutions are available online (http://www.win.tue.nl/ ~ lengelen/glt1112.php). How to install the Eclipse-based tools is described in the assignment concerning Xtext (http://www.win.tue.nl/ ~ lengelen/gltooti2011/xtext_assignment.pdf). 1

Upload: ngotu

Post on 19-Nov-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Generic Language Technology - TU/elengelen/gltooti2011/case_study.pdf · Generic Language Technology Case Study Introduction ... serves as an intermediate language between the rst

Generic Language Technology

Case Study

Introduction

This case study is meant to get you acquainted with domain-specific languages(DSLs) and model-driven software engineering (MDSE). You will apply MDSEby generating code written in the language Not Exactly C (NXC) based onmodels specified using a simple DSL.

First, you are asked to construct two DSLs: one that describes a path bylisting a number of coordinates on that path, and one that describes a path bylisting commands that would direct a vehicle along this path. The second DSLserves as an intermediate language between the first DSL and NXT code.

After defining these DSLs, you are asked to implement a transformationthat takes a list of coordinates as input and produces a list of commands thatdescribes the same path.

The last step of the case study is implementing two templates that can beused to generate code from models specified using the two DSLs. One templateshould take a list of coordinates and produce an NXT program that displaysthe path on the display of the NXT. The other template should take a list ofmovements and produce an NXT program that directs a vehicle along the pathspecified by the movements.

Getting Started

For this case study, you need to study a Lego vehicle, install and use softwareto program the programmable Lego NXT brick, and install and use variousEclipse-based tools.

The small Lego vehicle that is used for this case study is described on pages5 to 15 of the Lego Mindstorms NXT manual. The manual is available online(http://mindstorms.lego.com/en-us/support/buildinginstructions/8547/8547UserGuideEnglish.aspx).

The programmable Lego NXT brick should be programmed using NXC. Doc-umentation concerning NXC is available online (http://bricxcc.sourceforge.net/nbc/nxcdoc/).

The Bricx Command Center can be used to compile NXC programs andtransfer them to the NXT brick. It can be downloaded from http://bricxcc.

sourceforge.net/.We have prepared a number of tutorial assignments that should help you get

acquainted with the Eclipse-based tools. These assignments and their solutionsare available online (http://www.win.tue.nl/~lengelen/glt1112.php). Howto install the Eclipse-based tools is described in the assignment concerning Xtext(http://www.win.tue.nl/~lengelen/gltooti2011/xtext_assignment.pdf).

1

Page 2: Generic Language Technology - TU/elengelen/gltooti2011/case_study.pdf · Generic Language Technology Case Study Introduction ... serves as an intermediate language between the rst

Creating New Projects

The exercises do not explain how you should create a new project for yourXpand model-to-text transformation. Since this is an important part of thiscase study, we explain how to create such a project below. You can create anew Xpand project by following these steps:

• In the package explorer, right click and select New → Project. . .

• In the pop-up window, select Xpand → Xpand Project and click Next.

• In the next pop-up window, indicate that you want to use a project specificmetamodel and choose the JavaBeans Metamodel. Choose an appropriatename for your project and click Finish.

• Next, you need to add the plug-ins of your Xtext projects as dependen-cies. If you have not yet exported your Xtext projects as plug-ins be-fore, you need to do this now. In your new Xpand project, open the fileMETA-INF\MANIFEST.MF. Select the Dependencies tab and click the Addbutton and add the plug-ins you exported.

• Import the org.eclipse.emf.mwe2.launch plug-in in the same way.

• Save the MANIFEST.MF file.

• You can now create an Xpand template and a workflow file to execute thetemplate. Examples of such files are given in the Xpand assignment (http://www.win.tue.nl/~lengelen/gltooti2011/xpand_assignment.pdf).

2

Page 3: Generic Language Technology - TU/elengelen/gltooti2011/case_study.pdf · Generic Language Technology Case Study Introduction ... serves as an intermediate language between the rst

When you are asked whether you want to add the Xtext nature to theproject, click Yes.

Testing Your NXC Programs

There are three Lego vehicles available to test your NXC programs. You can usethese vehicles to test your software in office HG 5.43 on weekdays from 10:00 to12:00 and from 13:00 to 16:00. You do not need to make an appointment first.

3