please dont rip this site

12. Dictionaries

12.1. Chaining the Dictionary Element
As shown in Section 9.2. this section has already been mentioned, all the elements of the dictionary have a chain of fields, this combines the words of the dictionary. The chain field contains a pointer to the name field of the previous word, or 0 (for the "lower" element of the dictionary). If we know the title of a word field in a word, the corresponding FORTH parentheses can also be used to generate the addresses of other fields:

PFA (ncím --- pcím) generates the title of the parser from the name field of a dictionary element;
NFA (pcím --- ncím) enter the address of the search field from the title of the parser;
CFA (title pm) enter the address of the code field from the title of the parser;
LFA (pcim --- address) enter the address of the chain field from the heading address.

The title field of a word thus obtains the title of the name field of the word defined before:

PFA (Parameter Address)
LFA (chain field address)
@ (chain field content = address field of the previous word)

We can therefore move on the chain; another word to find the front of the chain:

LATEST (--- ncím) The address field of the last defined dictionary dictionary.

In the name field, the word "almost" is in the form of a FORTH garland; the difference is that the first three bits of the length of the bytes area do not belong to the length, and contain other information. So we do not write the word with COUNT TYPE, but with a special word:

ID. (ncím ---) it prints the name of the word whose name field is found in the vermin.

The following is the name of the last word defined:

: TODAY LATEST ID. ;

Now we can even list our dictionary:

: VLIST2
   80 OUT!
   LATEST
   BEGIN
      OUT @
      70> IF
        CR 0 OUT!
      ENDIF
      DUP ID.
      SPACE SPACE
      PFA LFA @
      DUP 0 =
   UNTIL
   DROP
;           

(the list begins with a new line)

(the worm: address)
(do not write over lines in a row?)



(name

spelling)

( next name field address) (if the chain field is 0, end)
(the dictionary)

How does this differ from your well-known VLIST? First, it does not stop when you press a key on the keypad. We can easily help you with this

? TERMINAL (--- f)

we must know the word; this will give you a true flag when you press a key on the keyboard (we have not handled it with KEY). Second, it does not list the same vocabulary that VLIST. How should this be understood? It turns out in the next section.

12.2. Search and Chain Dictionary It is
embarrassing to distinguish between the meaning of two words that are equally translated into "vocabulary". One is dictionary dictionary (eg, DP: Dictionary Pointer system name), which is a "physical" vocabulary, the other is vocabulary (known as VLIST, Vocabulary List), which is " logical "vocabulary, with a list of terms with indices. In FORTH, a "physical" dictionary can contain more "logic"; In addition to the FORTH dictionary, there are mostly EDITOR and ASSEMBLER dictionaries. By default, we are in the FORTH dictionary; then, for example, the words of the EDITOR dictionary are simply not found or recognized by the interpreter.
To use the words in the EDITOR dictionary, the EDITOR should be used as a search dictionary. (The "search dictionary" is quite a free translation of the original "context vocabulary", contextual dictionary expression.) At a given moment dictionaries can be a single search dictionary.


Two logical chains, physically mixed

The interpreter searches the words to interpret in the search context. The dictionary name makes the given dictionary a search dictionary.

So, for example, the

EDITOR

with the command prompt, you can see the words in the EDITOR dictionary (if loaded before). It is unnecessary to worry about how to get in EDITOR without the FORTH basic vocabulary:

The words of any dictionary in which the given dictionary is defined are chained to the words of the dictionary.

Ultimately, this means that

the words of the FORTH dictionary appear from every search dictionary.

We see this if we do a VLIST after the word EDITOR is executed. Standard VLIST lists the search dictionary. We can also make sure that our VLIST2 program does not do this, as it does not write the words in the EDITOR dictionary. The word LATEST with which our program starts starts is not the title of the top word of the chaining dictionary, but the search engine.
The chaining (originally current) dictionary is just one at a given moment.

Newly defined words are added to the chaining dictionary.

With the name of the dictionary, only the search dictionary will be changed; if you want the chaining dictionary to be the same, then a

DEFINITIONS

use the word that aligns the chaining dictionary to the search engine, the two will agree.
In reverse, the two dictionaries are aligned with the definitions : word: this changes the viewfinder to match the chain.
An old acquaintance, a new feature of FORGET: works only if the search and chaining dictionary is the same, otherwise it is broken by error.

12.3. Our own dictionaries
We can also separate one of the vocabulary from the other, we can create their own dictionaries. Defining the dictionary

Vocabulary

you have to enter the name of the new dictionary (as we have seen in the definitions). After defining a dictionary, you also use the word IMMEDIATE, which we will later discuss (see section 16 ). For example, if you write a user program, but do not want to know the user's nose, what are the auxiliary words written during the program buildup, you can lock these auxiliary words into a separate dictionary:

VOCRBULRRY REJTETT IMMEDIATE

When we write the words "hidden" we will do this as a search and chaining dictionary:

HIDDEN (this made him search)
DEFINITIONS (from a chaining)

If we are ready to write the auxiliary words, we want to create the final result in the FORTH dictionary:

FORTH DEFINITIONS
: VEGSO (but you want to use it in the program)
        ( READY words)
   HIDDEN
      (here comes the text of the program)
;

The fact that the REJTETT word is performed while compiling and not running VEGSO is the result of IMMEDIATE.
Since : you stop the search dictionary, if you want to define another word using the READER words, you will need to redefine the search dictionary after the next colon:

: VEGSO2 REJTETT
   (here comes the text of the program)
;

What was that about?
Summary of Chapter 12

The words learned:

PFA (ncím --- pcím) It generates a parsing address from the name field of a dictionary element.
NFA (pcím --- ncím) Enter the name of the search field from the title of the parser.
LFA (pcim --- address) Enter the address of the chain field from the parsing address.
CFA (pcs. Enter the address of the code field from the title of the parser.
LATEST (--- ncím) Returns the name field of the top element of the linking dictionary.
ID. (ncím ---) Specifies the name of the dictionary element whose name field was found in the verme.
FORTH (---) Dictionaries. Their name can be used to search for them.
EDITOR (---) Dictionaries. Their name can be used to search for them.
ASSEMBLER (---) Dictionaries. Their name can be used to search for them.
?TERMINAL (--- f) The returned indicator is true when you press a key on the keypad.
DEFINITIONS (---) The chaining dictionary is aligned to the search dictionary.
Vocabulary (---)
Defining word, so we use: VOCABULARY xxx
We created a dictionary called xxx.

Examples

12.1. Write in section 12.1. section of a VLIST2 section that will stop the listing by pressing any key!

: VLIST
   80 OUT!
   LATEST
   BEGIN
      OUT @
      70> IF
        CR 0 OUT!
      ENDIF
      DUP ID.
      SPACE SPACE
      PFA LFA @
      DUP 0 =
      ? TERMINAL OR
   UNTIL
   DROP
;

12.2. Write the names in the dictionary that start with an opening lock, so that it is tabulated so that the number of characters that can be entered can be divisible by 13. If there are more than 51 characters in a row, the next name is written in a new line.

: LIST
   80 OUT!
   LATEST
   BEGIN
      DUP 1+
      C @
      40 = IF
(---)



(crossing the lengthbyte)
(this is the first character of the name)
(if parenthesis)
        OUT @ 51> IF
          CR 0 OUT!
        ENDIF
        DUP ID.
        13 OUT @ 13 MOD -    SPACE
      ENDIF
      PFA LFA @
      DUP 0 =
UNTIL
   DROP
;


file: /Techref/language/FORTH/z80fig-Forth1_1g_files/dictionaries.htm, 34KB, , updated: 2018/11/8 20:09, local time: 2024/11/28 06:58,
TOP NEW HELP FIND: 
18.226.93.22:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://ecomorder.com/techref/language/FORTH/z80fig-Forth1_1g_files/dictionaries.htm"> fig-FORTH 1.1g Dictionaries</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to ecomorder.com!

 

Welcome to ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .