-----

Compiler Step 2: Check Syntax

-----

This step checks the syntax of each form in the code. It also removes as much variant syntax as possible, to simplify work in later steps. However, rewriting rules applied in this step must (a) not introduce new function names and (b) not require that variables in the code have unique names.

Everything is done in one recursive walk through the structure, so each form is considered once. For each form, the compiler checks the following:

Most forms are checked using general rules and the information in their table entry. Special-case code is provided for forms requiring special handling and/or rewrite rules.

Rewriting rules

A variety of forms require special handling in step 2, either because their syntax is complex or because rewriting rules can be applied.

Certain forms simply have complex syntax that must be checked: let, let*, set!, multiple-set!

The complex syntax of do is checked. Also, the increment form is filled in for clauses where it has been omitted.

While and scan are rewritten to take two inputs, i.e. to package their inside forms (if multiple) inside a begin form.

The complex syntax of scan is checked. If the scanner argument has been omitted, a scanner argument of storage-order-scan (our local default) is supplied.

The constant pi is inline coded.

Constant fractions (exact non-integers) are converted to inexact reals.

The following functions take a variable number of arguments: <, <=, =, >=, >, sample-<, sample-<=, sample-=, sample->, sample->=, +, *, -, /, min, max, and, or. Multi-ary forms are rewritten as binary. Nullary forms, when legal, are rewritten into the appropriate identity value. Unary forms simplified, except that unary - remains.

Forms headed by cond are rewritten into (binary) forms headed by if. If a cond clause contains nothing besides a test, it is rewritten to return #t. This is not correct in main scheme, because non-booleans can be used as booleans. However, the coprocessor's sublanguage does not allow non-booleans to be used as booleans. The primary reason for allowing this in scheme is for the benefit of list processing functions such as member, and the coprocessor's sublanguage does not support lists.

The following functions are rewritten using more primitive operations: zero?, positive?, negative?, even?, odd?.

The following functions are rewritten to remove variant syntax: sheet-ref, unscaled-sheet-ref, shift-sample, nearest-sample

Values forms with only one input are simplified.

Multiple-set! forms with only one variable are rewritten as set! forms.

-----

Ownership, Maintenance and Disclaimers

Manual Top Page

Last modified

-----

Ownership, Maintenance and Disclaimers

Manual Top Page

Last modified