Quick questions on xtext

Bold ( :-) ) experiment: using three lines of JavaScript for this set of revision questions, just to show/hide model solutions, rather than either not giving model solutions or sticking them on a separate page. Please let me know if it doesn't work. (Obviously it won't if you have JavaScript turned off, but I'm guessing that's rare these days.)

  1. Write a rule, called Song, in xtext, which specifies that a Song is specified by the keyword song followed by an ID, which should be assigned to variable opus. Show solution
  2. (a different style for telling you what to write!) Write a rule called Concerto that should let users write lines like:
    concerto k466 "piano in D minor"
    where "concerto" is a fixed keyword in the DSL, "k466" is an ID, which should be saved in variable opus, and "piano in D minor" is a STRING which should be saved in variable description. Show solution
  3. Write a rule called Work that specifies that a Work is either a Song or a Concerto. Show solution
  4. Write a rule called Concert that specifies that a Concert is given by the keyword "concert" followed by a list of Works in curly brackets. The list of Works should be called programme. Show solution

This page is maintained by Perdita Stevens (perdita@inf.ed.ac.uk)


Home : Teaching : Courses : Sdm 

Informatics Forum, 10 Crichton Street, Edinburgh, EH8 9AB, Scotland, UK
Tel: +44 131 651 5661, Fax: +44 131 651 1426, E-mail: school-office@inf.ed.ac.uk
Please contact our webadmin with any comments or corrections. Logging and Cookies
Unless explicitly stated otherwise, all material is copyright © The University of Edinburgh