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

naming: methods to recognize various lexemes #17

Open
ruv opened this issue Sep 8, 2020 · 1 comment
Open

naming: methods to recognize various lexemes #17

ruv opened this issue Sep 8, 2020 · 1 comment
Labels
api An API method semantics consideration naming Choosing names, the art v4-review Related to the proposal v4 by Matthias Trute

Comments

@ruv
Copy link
Collaborator

ruv commented Sep 8, 2020

Recognizer v4 API suggests to use the prefix rec- for names of recognizers. E.g. rec-num or rec-nt.

A disadvantage is that it's a truncated English word, and it appears as a noun at the first glance — due to association to "record" or "recognizer". And also due to "rectype" term that is noun. But by convention, it should be a verb for such a Forth word (or an abbreviation to a verb at least).

I would suggest to use the complete English word and the prefix recognize- for such words. E.g. recognize-nt.

Concerning the second part, it's better if it is either a complete English noun, or an appropriate data type symbol from the standard types.

E.g. recognize-number, recognize-double, recognize-float, recognize-xt, recognize-word.

If we need to recognize the different lexeme formats for the same token, we can use the third part. E.g. recognize-float-e to recognize a float from a literal representation (lexeme) contains e symbol only, recognize-double-dot to recognize double-cell number from a literal that has a trailing dot only, etc.


recognize-word can be a compound recognizer that can return ( xt td-xt ), or ( xt td-xt-imm ), or ( xt1 xt2 td-xt-dual ) or ( nt td-nt ).

@ruv ruv added api An API method semantics consideration v4-review Related to the proposal v4 by Matthias Trute naming Choosing names, the art labels Sep 8, 2020
@ruv
Copy link
Collaborator Author

ruv commented Sep 14, 2020

If a recognizer is just a kind of transformation for the perceptor, a better name is perceive-{something}. E.g.

: perceive-xt ( c-addr u -- xt td-xt | 0 )
  'perceive execute-balance2 2>r token>xt? 2r>
  2 pick if 2drop exit then nfdrop 3 + ndrop 0
;

This recognizer recognizes the only lexemes which are recognized by the perceptor as ordinary words.

Such recognizer cannot be included into the perceptor directly (due to unlimited recursion). It can be only used in another recognizers to be applied to the different lexeme. And the different name pattern also indicates this different semantics.

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 naming Choosing names, the art v4-review Related to the proposal v4 by Matthias Trute
Projects
None yet
Development

No branches or pull requests

1 participant