Laundry Lists for C Compiler Projects

Types you are Actually Supposed to Handle

  1. int (char, long etc all refer to 32-bit signed integers)
  2. floats (float and double refer to 64-bit signed floats)
  3. FILE and WINDOW predefined types
  4. structs whose fields may be any of the above types
  5. 1-D pointers to base types (int *, char *, float *)
No arrays of arrays, pointers to pointers, structs of structs... no multilevel things, period.

Semantic Errors that You Should Detect

  1. Undeclared variables, including undeclared functions.
  2. Conflicting declarations for a variable (variable redeclared). This includes trying to declare a variable whose name is a typedef-name, or trying to typedef the name of a declared variable.
  3. Type mismatches, e.g. assigning a struct to an array variable. This includes passing the wrong type of parameter to a function, as well as misusing function return types.
  4. Falling off the end of a non-void function
  5. Returning a value from a void function

Unimplemented Features

You should report occurrences of these features as a fatal semantic error. Note that function prototypes and typedef's involving these features should be accepted; variable declarations (including parameters) of these types should result in an error. The goal is to support almost all system header files, even though only a subset of the language is implemented.

Equivalent types

Note that treating unions as equivalent to struct's would be cool, but I'd written earlier that you didn't have to implement them, so it shall be. But that means you have to produce "unimplemented" messages for them, which might be more work than treating union as another name for struct.