Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: token descriptors considered harmful #22

Open
ruv opened this issue Dec 5, 2024 · 0 comments
Open

API: token descriptors considered harmful #22

ruv opened this issue Dec 5, 2024 · 0 comments
Labels
api An API method semantics consideration

Comments

@ruv
Copy link
Collaborator

ruv commented Dec 5, 2024

When creating a text translator that generates intermediate code, or code in some not native format (but still using the native FVM), or code for an independent target VM, we must define at least the following parts:

  1. The token compilers (like lit,, compile,, compilers for control-flow, etc).
  2. The token translators (it's enough to load the definitions for token translators against the new token compilers).
  3. The recognizers (load their definitions against the token compilers and token translators).
  4. The higher-level words that generate code (load their definitions against the token compilers and token translators):
    • the words related to control-flow (like if, else, then, begin, again, etc);
    • syntax constructs like ['], [char], s", c", to, is, action-of, postpone;
  5. The words related to the return stack (like >r, r>, r@, 2>r, 2r>, 2r@, rdrop, 2rdrop, etc).
  6. Local variables (if any).

If the Recognizer API automates the postpone action via a reproducer action, it prevents the item (2) to be implementable at all, because it uses the system's compile,, see:

If the Recognizer API dictates that only a special system-specific method shall be used to define a token translator from two or three actions, then the Forth text interpreter itself depends on STATE, because it uses STATE to select a one or another action. This means that your special text translator still depends on STATE too, and you have to provide actions that you don't actually needs. See also:

With token translators (instead of token descriptors), the Forth text interpreter by itself is free of STATE.
See also:

@ruv ruv changed the title API: token **descriptors** considered harmful API: token descriptors considered harmful Dec 5, 2024
@ruv ruv added the api An API method semantics consideration label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api An API method semantics consideration
Projects
None yet
Development

No branches or pull requests

1 participant