W. M. Waite
This document describes a strict subset of ANSI C (ANSI/ISO 9899-1990) that has only simple variables of types int and float, and no function calls. Nevertheless, it illustrates a number of important concepts in programming languages:
The document itself was generated from an Eli specification of an analyzer for the C subset. That specification is an example, at the level of an introductory compiler construction class, showing how common language constructs are described using Eli.
Section 1 defines the C subset by means of a context-free grammar extracted from ANSI/ISO 9899-1990. An abstract syntax tree structure describing the essential semantics of the subset is given in Section 2, along with the Eli specifications necessary to build the AST corresponding to any legal program.
The computations specified in Section 3 decorate the nodes of the tree with information about the binding of identifiers and the type of expressions. Section 4 uses these decorations to report semantic errors.
Eli can generate an executable ``lint'' processor for the C subset from the specifications used to derive this document. If these specifications are combined with Eli specifications for translation and encoding tasks, Eli can generate a complete compiler for the C subset.
The translation specification will need to deal with the following important issues: