[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.4.3 Functional languages: Second-stage Lisp

Setup

Perform the weekly set up instructions for project 1, homework c.

What to hand in

Report (a) all the lisp functions you’ve written and (b) a file containing your deftests and (c) ‘repl.txt’ coming from you saving the REPL showing these all running.

Exercise 1: Left symbols

Write code to find the list of left-hand-side symbols in the rules

(deftest !lefties ()
	(test
		'(sentence noun-phrase verb-phrase ; you fill in the rest
		(lefties *grammar1*))))

Exercise 2: Right symbols

Write code to find the list of right-hand-side symbols in the rules

(deftest !righties ()
	(test
		'(Article Adj* Noun ; you fill in the rest
		(righties *grammar1*))))

Exercise 3 : Terminals

Write a deftest that reports the terminals of a grammar (terminals are righties that are not lefties).

Exercise 4 : Lint

Write a deftest showing code that reports lefties that are never righties (this is an error: exception, each grammar has one top-most start symbol. So we will say that the first lefty is the start symbol and exempt from this check).

Note that, to test this code, you’ll have to invent a grammar that has these problems.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on April 19, 2011 using texi2html 5.0.