SD Core Solo for Linux LS2.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.

The records on this page are those of a stock account VOC. On SD Core Solo for Linux the installer's account step copies the whole of the shipped newvoc into the account's VOC, so the shapes are the same; the counts below are Solo's own, those of the shipped newvoc.

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 the shipped VOC holds#

The VOC a new account starts with is newvoc in the system directory: 441 records, counted by each record's own field-1 type character (the type is the first character; a record whose field 1 reads Verb to ... is V):

Type Count
V 212
K 218
F 7
PA 1
S 1
Q 1
X 1

The four keyword-verbs are among the 218 K records. break, count, display and off are counted as keywords here and are also verbs, so Solo has 212 + 4 = 216 verbs, the number on the syntax card. No R record is shipped.

Your account's VOC starts as a copy of exactly this, and what you add to it is yours. The account and grant commands are not in it — see Differences from SD Core for Linux LC2.0-0 in the GettingStarted set. (SDSYS's own VOC, which nobody signs in to, is built from the larger voc_template: 446 records.)

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 pointers into @SDSYS#

Seven of the shipped F records have a data path that begins @SDSYS/. They point at files in the system directory — on Solo, the installation directory itself — that the account needs:

VOC id Field 2 Field 3
voc voc @SDSYS/voc.dic — the dictionary
newvoc @SDSYS/newvoc @SDSYS/voc.dic
syscom @SDSYS/syscom
$map @SDSYS/$map @SDSYS/$map.dic
dict.dict @SDSYS/dict.dic @SDSYS/dict.dic
global.bp.out @SDSYS/global.bp.out

global.bp.out is the SD Core for Linux server's directory of compiled programs on a managed computer, and is empty otherwise; you cannot write to it, admin or not. See Managed mode in the GettingStarted set.

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 — 174 of the shipped verbs
IN number internal verb n, handled by the command processor itself — 37 verbs
OS text an operating-system command — sh, and nothing else
CS path a locally cataloged function

The first three rows account for all 212 of Solo's V records. The remaining four 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 needs admin is checked by the verb's own code, not by a security subroutine — but the mechanism is there for a site that wants a verb guarded rather than absent. Field 4 does matter to the deny list (see Managed mode in the GettingStarted set): SD denies a verb by what it runs — the same field 2, field 3 and field 4 — so two names that dispatch identically are denied together.

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 under the same rules, 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 the shipped 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  LS2.0-0

This is $release, and it is the shipped VOC'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 display two plain files in the system directory, licence and contrib, in ~/SDCoreSolo, and need no shell.

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.