MeAmAnUsername / pie

Pipelines for Interactive Environments
Apache License 2.0
0 stars 0 forks source link

name generation #2

Open MeAmAnUsername opened 4 years ago

MeAmAnUsername commented 4 years ago
MeAmAnUsername commented 3 years ago

Implementation:

  1. Generate Java code without translating names from PIE. For fresh variables, use a prefix that could never be allowed in PIE: $.
  2. Find all names in generated Java AST.
  3. Remove $ if that does not result in a name that already exists.
  4. Replace $ with _ if that does not result in a name that already exists.
  5. Replace Java reserved words with _keyword if that name does not already exist. (e.g. class -> _class)
  6. Replace Java reserved words with $keyword if that name does not already exist. (e.g. class -> $class)

Note: this implementation does not take into account multiple times the same name. Instead of using $, append _X, where X starts 1, then 2 etc?