udem-dlteam/pnut

Top level characters are not supported

Opened this issue · 0 comments

Context

The following program crashes when compiled by pnut-sh. This is because the corresponding character ident is not yet defined. There are a few options to solve this:

  1. Generate all globals at the end, after the runtime library and character literal constants. This changes the structure of the code and globals are often declared beside functions using them so we probably don't want that.
  2. Generate the character literal constant before defining the global variable. This means character constants can be defined in many places and doesn't look nice.
  3. Use the numeric value instead of the character literal constant. Maybe add a comment beside it indicating what the ascii code correspond to.
char chr = 'a';

void main() {
  return;
}