A1 - ECE 251 Assignment#1 Abstract Datatype Language(v2 Patrick Lam Due(1 Test cases September 28(2 Code October 5 Be sure to consult the

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ECE 251 Assignment #1: Abstract Datatype Language (v2) Patrick Lam * Due: (1) Test cases, September 28; (2) Code: October 5 Be sure to consult the clarifications posted on the web page as well as the Javadoc for my sample solution for hints. 1 Problem Description Suppose that you are assigned the job of teaching some high school students about abstract datatypes as part of a summer enrichment programme. You do not know if these students have any programming experience and you want your class to be accessible even to those who do not have any prior programming experience. This is a brief summer programme, so you don’t have time to start by teaching them a conventional programming language: you’ll never get to abstract datatypes if you start with procedures etc. What to do? One option is to make this course just a pencil and paper exercise. Is there another option? Thankfully you’ve taken ECE251, so you have some skills at your disposal. 2 Solution: Design a Language We design (and implement) a small domain-specific language to enable introductory students to experiment with abstract datatypes. Let us call this language ADL for ‘abstract datatype language’. 2.1 Language Overview Variables in ADL have one of three types: atom (single value), list, or tree. Variables do not need to be explicitly declared. There are three kinds of statements: read, write, and assignments. Assignment statements have some kind of operation on the right-hand side. Variables are introduced by read statements and assignment statements. Read and write statements work with three different file types (one for each kind of variable): atom (single value), txt (list), xml (tree). A read statement introduces a variable with the same name as the file. For example, the following statement introduces a new variable named book of type tree: read book.xml * Thanks to Prof. Derek Rayside for formulating and writing up this assignment! 1 Write statements are similarly simple: they are of the form write var , and cause a file named output/var.ext 1 to be written to disk, where var is the name of the variable and ext is the extension that corresponds to to the type of the variable. Print statements instead write the variable to standard output (to help you with interactive testing). Assignment statements are the most complicated. The LHS names the variable being intro- duced. The RHS calls built-in functions. A more sophisticated version of ADL might also include tables and graphs. However, including those abstract datatypes in the version of ADL for this assignment would make this assignment take too long to complete. Moreover, you will work with tables on the next assignment. 2.2 Examples Consider a document as an ordered tree. This may take you a second. Think of a technical document that has numbered chapters and sections: for example, paragraph I.2.b of the Canadian Charter of Rights and Freedoms guarantees freedom of thought, belief, opinion, and expression....
View Full Document

This note was uploaded on 10/28/2010 for the course ECE 493 taught by Professor Lam during the Spring '09 term at Waterloo.

Page1 / 7

A1 - ECE 251 Assignment#1 Abstract Datatype Language(v2 Patrick Lam Due(1 Test cases September 28(2 Code October 5 Be sure to consult the

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online