5.2 The Extended Syntax Rules

<function> ::= ftype PROCEDURE id (<id list>); <statement>; = ⇒

   (PUTD (QUOTE id)

(QUOTE ftype)

(QUOTE (LAMBDA (<id list>) <statement>)))

<id list> ::= id =⇒ id

id, <id list> =⇒ id <id list>

=⇒ NIL

<statement> ::= <expression> =⇒ <expression>

<proper statement> = ⇒ <proper statement>

<proper statement> ::=

<assignment statement> =⇒ <assignment statement>

<conditional statement> =⇒ <conditional statement>

<while statement> =⇒ <while statement>

<compound statement> =⇒ <compound statement>

<assignment statement> ::= id := <expression> = ⇒

(SETQ id <expression>)

<conditional statement> ::=

IF <expression> THEN <statement1> ELSE <statement2> =⇒

   (COND (<expression> <statement1>)(T <statement2>))

IF <expression> THEN <statement> = ⇒

(COND (<expression> <statement>))

<while statement> ::= WHILE <expression> DO <statement> = ⇒

(PROG NIL

LBL (COND ((NULL <expression>) (RETURN NIL)))

<statement>

(GO LBL))

<compound statement> ::=

BEGIN SCALAR <id list>; <program list> END = ⇒

(PROG (<id list>) <program list>)

BEGIN <program list> END = ⇒

(PROG NIL <program list>)

<< <statement list> >> =⇒ (PROGN <statement list>)

<program list> ::= <full statement> =⇒ <full statement>

<full statement> <program list> = ⇒

<full statement> <program list>

<full statement> ::= <statement> = ⇒ <statement> id: =⇒ id

<statement list> ::= <statement> = ⇒ <statement>

<statement>; <statement list> = ⇒

<statement> <statement list>

<expression> ::=

<expression1> . <expression2> = ⇒

(CONS <expression1> <expression2>

<expression1> = <expression2> = ⇒

(EQUAL <expression1> <expression2>)

<expression1> EQ <expression2> = ⇒

(EQ <expression1> <expression2>)

<expression> =⇒ (QUOTE <expression>)

function <expression> =⇒ (function <expression>)

function(<argument list>) =⇒ (function <argument list>)

number =⇒ number

id =⇒ id

<argument list> ::= () =⇒

<expression> =⇒ <expression>

<expression>, <argument list> =⇒ <expression> <argument list>

Notice the three infix operators . EQ and = which are translated into calls on CONS, EQ, and EQUAL respectively. Note also that a call on a function which has no formal parameters must have () as an argument list. The QUOTE function is abbreviated by ’.