#include <stdio.h>

// rather than using 'const int' variables, which are not really consts
// but are actually 'readonly' variables, the use of enums actually gives
// us a name that can be used in a const context in C.

// And it appears that an enum with given values actually can specify the
// same value twice with different names.

// This neatly solves the problem of translating Imp %constinteger's into
// C without requiring ugly #define statements with #undef's at the end
// of a procedure to undo them.  Especially in nested contexts!  The only
// difficulty is that the current compiler outputs code as it is parsed
// rather than saving it all in an AST and then generating afterwards, so
// collecting multiple %const's into one statement to be places at the
// start of a procedure, like this, is awkward:

enum consts_in_this_scope {
  LD  = 42,
  ST  = 67,
  LDA = 42,
  STA = 67,
};

// so this is the workaround, but unfortunately it's a bit verbose and ugly.

enum MUL { MUL = 22 };
enum DIV { DIV = 12 };

// (Unfortunately this hack does not handle %real constants so the original
//  scheme may still be needed.  Unless... we just use "const float" etc.
//  and not worry about the problem, as the only awkward cases where we
//  need actual constants (such as array bounds or switch labels) all need
//  integers anyway.  Likewise string constants.)

int main(int argc, char **argv) {
  int i;
  i = ST;
  
  switch (i) {
  case LDA:
    break;
  case MUL:
    break;
  case STA:
    break;
  default:
    break;
  }
  
}
