kjosib / booze-tools

Booze Tools will become the complete programming-language development workbench, all written in Python 3.9 (for now).
MIT License
14 stars 1 forks source link

Reserved-Word Table Integration #36

Open kjosib opened 4 years ago

kjosib commented 4 years ago

Turns out reserved words are a common feature in programming languages: they provide structure but otherwise have void semantic content. Its also traditional to use a "perfect hash" as a check for reserved words in a scanner that may otherwise confuse them with identifiers (and this is normal).

An interesting kind of declaration would be %reserve ... with the ... being a whitespace-separated list of entries which

  1. get marked as "void tokens", and
  2. are available somehow in the resulting tables.
kjosib commented 3 years ago

In retrospect, you might care about things like the position of reserved words as anchors for structures they delimit, for error-reporting. Therefore, calling them "void" doesn't necessarily fit the bill. However, it would still be cool to integrate a perfect-hash feature somehow -- and anyway, the "void" marker might be a nice configurable option.