nes-pascal

Program structure

A program contains:

  1. the program keyword;
  2. a program name;
  3. a semicolon;
  4. an optional const section;
  5. an optional var section;
  6. zero or more procedure declarations;
  7. a block beginning with begin;
  8. a sequence of statements;
  9. the end keyword;
  10. a final period.

Example:

program Minimal;

const
    DefaultBackgroundColor: nes_color = $21;

var
    BackgroundColor: nes_color;
    FrameCounter: byte;
    RenderingEnabled: boolean;

procedure Initialize(Start: byte; Enabled: boolean);
begin
    FrameCounter := Start;
    RenderingEnabled := Enabled;
end;

begin
    BackgroundColor := DefaultBackgroundColor;
    Initialize($00, true);
    nes.set_background_color(BackgroundColor);
    nes.run;
end.

The declaration sections must appear in this order. The main block completes the program and contains the top-level initialization sequence.