SD Core for Linux LC2.0-0

SD VOC - Structure and Usage

The Vocabulary file: all ten record types, and every field of each one.

The VOC — Vocabulary — is the file that makes a command line work. Type a name, and the command processor looks it up here. The name of a verb, a file, a paragraph, a stored sentence, a keyword — all of them are records in the VOC. This page is about the record types, their fields, and what the verbs that manage the VOC do to them.

SD folds case, so a command may be typed in either case. Commands are shown here in lower case, which is what this port uses on disk. In the tables, italics mark something you supply and bold marks a word typed as it stands; braces mark an optional part.

Every record on this page was read from a stock account VOC. The records were written by create.account, which copies them from newvoc — not voc_template, which is SDSYS's own, larger VOC and what the counts below are taken from. Every ordinary account gets the same set; there is no smaller or larger starting VOC to choose between any more.

The ten record types#

Field 1, character 1, is the type. The rest of field 1 is free text and is ignored, so a verb record whose field 1 reads Verb to compile SD BASIC program is type V and the rest is a comment. The first character is load-bearing and the remaining thirty are not.

Type Name What it does
V verb the common case — dispatches to a program or an internal routine
K keyword a query-processor keyword; four of these are also verbs
S sentence one stored command line
PA paragraph several stored command lines, with flow control
Q Q-pointer an indirect pointer to a file in another account
F file a file — local, or pointing into @SDSYS
R remote a pointer to a record in another file, re-read and re-parsed
X text miscellaneous data — not a command
D descriptor a data descriptor, which is what dictionary records are

PQ is a valid type and is refused. PROC is not supported in SD. A record of type PQ is reported as "PROC is not supported" rather than being dispatched, because the record itself is valid PROC and it is the interpreter that is gone.

What SDSYS's own VOC holds#

Counted directly from voc_template in the system directory — SDSYS's own VOC, 448 records, by each record's own field-1 type character:

Type Count
V 209
K 218
F 14
PA 4
S 1
Q 1
X 1

The V count here is the literal type character, not the dispatchable total. break, count, display and off are type K — the four keyword-verbs described below — so the 213 figure used elsewhere on this page (and on the syntax card) for "everything the command processor can run as a verb" is this 209 plus those four. No R record is shipped.

An ordinary account's newvoc holds 388 — the same shape of table, smaller only because it lacks SDSYS's own administration verbs and a few system file pointers; it is not a different kind of VOC, and every ordinary account's copy is identical.

Being in the VOC is not evidence a command works. A record whose type field does not read V (a record whose type field read Verb - Full screen editor, say) looks callable and is refused at dispatch. edit is a real V record and works. Check the type field, not just the name.

The F record — a file#

001  F
002  bp
003

This is the bp entry — the BASIC source file. Field 1 is F, field 2 is the operating-system path to the data portion, and field 3 is the path to the dictionary portion. An empty field 3 means the file has no separate dictionary.

Field
1 F, optionally followed by a comment
2 data path — a name in the account directory, or @SDSYS/name for a system file
3 dictionary path, or empty if none

The seven pointers into @SDSYS#

A stock account VOC carries seven F-records whose data path begins @SDSYS/. They point at files in the system directory that every account needs:

VOC id Field 2
voc @SDSYS/voc.dic (field 3 — the dictionary)
newvoc @SDSYS/newvoc
messages @SDSYS/messages
syscom @SDSYS/syscom
$MAP @SDSYS/...
dict.dic @SDSYS/...
$ipc (system IPC file)

These are read-only to a network session: they can be opened and read, and every way of writing to them is refused. SDSYS is exempt; an ordinary account cannot write these files.

The $ACC record#

001  F
002  .
003

$ACC is the account itself. Field 2 is ., which means the current account directory. It is how a program opens "the account I am in" by name rather than by path.

The V record — a verb#

001  V
002  CA
003  $CREATEF
004

This is create.file. Field 2 is the dispatch type, field 3 is the target, and the remaining fields carry options.

Field 2 Field 3 What it does
CA catalog name a cataloged program — 169 of the shipped verbs
IN number internal verb n, handled by the command processor itself — 39 verbs
OS text an operating-system command — sh, and nothing else
CS path a locally cataloged function

The first three rows account for all 209 of SDSYS's V records (none shipped is CS). The other four of its 213 verbs are the keyword records described above — break, count, display and off — where field 2 holds a keyword number rather than a dispatch type, and it is field 3 that marks the record as a verb.

Field 4 carries dispatch options and field 5 names a security subroutine. If field 5 is present, that subroutine is called before the verb runs and can refuse it. None of the shipped verbs uses field 5 — what SDSYS alone can do is withheld by giving or withholding the VOC record itself, not by a security subroutine — but the mechanism is there for a site that wants a verb guarded rather than absent.

Internal verbs#

IN verbs are numbered, and the numbers are positional in the command processor's dispatch list. Several names share one: off and quit are both internal verb 1, and clr is internal verb 2. The clear.data, clear.input, clear.prompts and clear.select verbs are internal verbs 19, 25, 20 and 6.

The four keyword-verbs#

Four records ship as a keyword and a verb in one: break, count, display and off. Their field 2 is the keyword number the query processor uses, and fields 3 onward are a complete verb record, which the command processor re-parses when the name is typed as a command.

This matters for counting what an account has. A tally of VOC records whose field 1 begins with V misses all four, and count is not a marginal verb.

The Q record — an indirect pointer#

001  Q
002  SDSYS
003  accounts

This is sd.accounts. Field 2 is the account name, field 3 is the file name in that account. set.file writes Q-pointers; see below. The target of set.file may itself be a Q-pointer, which makes a chain (not recommended, but it opens): each link is followed with the same account test, so a chain cannot reach where its links alone could not.

The R record — a remote record reference#

001  R
002  mylib
003  listbig

This is an R-record called, say, bigfiles. Field 2 is the file name, field 3 is the record id of the sentence in it. An R-record is re-read and re-parsed every time it is used, so editing the referenced record changes what the command does without touching the VOC entry. SD ships no R-record any more: the ten ready-made list sentences (listf, listfl, listfr, listk, listpa, listph, listq, listr, lists, listv) and the sd.voclib file that held them were removed in 2.0-0. To list the records of one type, ask the query processor: list voc with type = "V" ("F" for files, "K" for keywords, "PA" paragraphs, "PH" phrases, "Q" Q-pointers, "R" R-records, "S" sentences).

The S record — a sentence#

001  S
002  DISPLAY <<@PATH>>

This is where. A sentence is one stored command line. Typing its name runs that line with anything else you typed appended, so a sentence is a command with its first arguments filled in.

The PA record — a paragraph#

001  PA
002  TERM ANSI
003  TERM 120,36

This is login, the paragraph that runs at sign-on. A paragraph holds several lines and has flow control: if, go, stop, abort, display, pause. Paragraphs nest, and abort unwinds all of them.

data lines are read ahead of the verb, not executed in sequence. Before a verb runs, the command processor scans forward over any immediately following data, comment and blank lines and stacks their text as typed-ahead input.

The PH record — a phrase#

001  PH
002  GRAND.TOTAL "'L'"

A phrase is a stored fragment that is substituted into a command line wherever its name appears. PH is treated as S for most purposes — the difference is that a phrase is designed to be used inside another command rather than typed on its own. The record above is a phrase a site might add: named gt.l, say, it expands to grand.total "'L'" wherever gt.l appears in a query.

No phrase ships in the VOC. The two that did, no.grand.total and without, were removed in 2.0-0; write grand.total "'L'" and with no in the command instead.

The K record — a keyword#

001  K
002  26

This is ne, the not-equal keyword. Field 2 is the keyword number the query processor uses. Keywords are not commands in their own right; they are the words the query processor — LIST, SELECT, SORT and the rest — recognizes inside a command line. all is K with number 5; and is K.

A K record can also be a command. When its fields 3 onwards are another VOC record (a V record, say), typing the K record's name runs that record as if it had been typed instead:

001  K
002  1
003  V
004  CS
005  /home/app/bp.out/report

This works for a locally cataloged subroutine too. The object is found by the last part of the pathname in field 5, which is the name it was cataloged under, so a program cataloged under a call name different from its program name is not reached this way.

The 218 K-records in a stock VOC are the query processor's vocabulary, and they are what makes a sentence like list stock with qty > 100 by supplier parse.

The X record — text#

001  X
002  LC2.0-0

This is $release, and it is SDSYS's only X-record. An X-record is not a command — it is miscellaneous data the VOC holds so that a program can read it by name with read from BASIC or ct from the command line. Two X-records that an account may add are read by SD itself and change what a command line does: $private.voc and $voc.parser, described on the next pages.

The license and the contributor list are not VOC records at all, despite looking like the obvious candidates. config gpl and config contrib, which work in every account, display two plain files in the system directory, sdsys/licence and sdsys/contrib.

Continued in#

SD VOC - Using and Managing the VOC — how the command processor uses the VOC, the verbs that manage it, and account creation.

SD VOC - A Private Vocabulary and Your Own Record Types — the two optional X records $private.voc and $voc.parser.