; PCL.DOC.9 & SNARK:PCL.DOC.7 27-May-81 1019 PAGE 1 Programmable Command Language Page 1 This defines the stored command language which will completely replace the current CMU Command Generator language; any suggestions should be sent to DK32 on any Computation Center system, or to KING at ARPANET site CMUC, or to David King at the Carnegie-Mellon University Computation Center, Pittsburgh, 15213. The system as it is currently implemented does not include all of the features described here, those features not currently available are indicated NYI (not yet implemented). This is NOT intended to be a general user document; it was originally the designer's own notes on what he was making, and it grew into something which could be read by the initiated. Accordingly, complaints and recommendations for this document of a stylistic nature (not concerned with technical correctness) would be a waste of time. User documentation is being written. ^L ; PCL.DOC.9 & SNARK:PCL.DOC.7 27-May-81 1019 PAGE 2 CHAPTER 1 EXEC COMMANDS RELATING TO THE COMMAND LANGUAGE 1.1 DECLARE COMMAND DECLARE (for PCL) [switches] object-type names DECLARE (for PCL) PCL-ROUTINES (from files) [filespec,filespec,...] DECLARE (for PCL) INTEGER-VARIABLE (named) name DECLARE (for PCL) STRING-VARIABLE (named) name DECLARE (for PCL) SYNONYM (to new name) NEWNAME (old command named) OLDNAME DECLARE (for PCL) ENVIRONMENT (from files) filespec,filespec,... switches: /CONFIRM /NOCONFIRM This command defines for the Exec a global variable, any number of PCL Commands or Procedures, a Synonym, or an entire Exec environment containing a collection of such objects. For a variable the variable is immediately defined; PCL variable names are alphanumeric strings, including the underscore character. For a PCL-routine the Exec reads the files provided and converts them into an internal representation; if no files are specified the Exec reads the source from the terminal (this last feature is not yet implemented). If the PCL routine file contains any command definitions, the name of the commands as given in the source file COMMAND statements are entered in the Exec's standard command table. If the command name in the source file contains any underscores, they are turned into hyphens before being placed in the command table. A PCL source file may also contain definitions for global variables; a line containing simply INTEGER or STRING will result in that variable being defined, the same as if a Declare Integer or Declare String command had been issued. It can also contain synonym definitions, and can remove original Exec commands, with lines like SYNONYM K LOGOUT; NOORIGINAL PLOT; ^L ; PCL.DOC.9 & SNARK:PCL.DOC.7 27-May-81 1019 PAGE 3 EXEC COMMANDS RELATING TO THE COMMAND LANGUAGE Page 1-2 The Declare command, by default, confirms its actions. The /NOCONFIRM switch suppresses this, as does the Set Default Declare /NoConfirm command. The /CONFIRM switch enables confirmation, even when confirmation has been turned off by a Set command. In the case of a procedure the program consists of a procedure declaration in the form of a , as given below (see section 2.1), page 2-1). In the case of a command declaration, the first line contains the keyword COMMAND and the name of the command, in the same fashion as a procedure source file; similarly, it may be followed by an optional parameter list, which may be used to enter the parameters from the terminal without the need to use the complex PARSE statement (described below in section 2.3 on page 2-3). There are two ways to deal with the parameters to a command: 1. You can parse them with the PARSE statement. In this case you leave out the parameter list and have the first thing in your definition be the BEGIN to start the command program. (see PARSE example in section 2.3 page 2-5). 2. You can accept a less flexible mechanism and provide, in parentheses, a brief description of each parameter: What type, default, guide word, and the name of a variable into which the value will be stored. Then, in the text of the command program, you do no Parses but only reference the variables. Each parameter description looks like this: ParameterType [(Options)] : VariableName where the parameter typed on the command line is placed in VariableName before the command program starts. The type of the variable will be appropriate to the type of the parameter. The ParameterTypes are as described below (see section 2.3 on page 2-3) in the definition of the Parse statement, as are the options available. Note that EOL is not a valid Field-type in this context; command arguments are terminated by carriage return by default. Also, there may be no variable or system procedure references in the field-type or field-options; for instance, the option 'HELP "repeat count"' is legal, but 'HELP HelpString' is not. One additional Parse-option is available in this context: the option "ERROR " will cause the command text to be started at that label if the argument does not match the Field-type specified; if no ERROR option is provided (which we expect to be the usual case) then a standard fatal error message appropriate to the Field-type will be issued if the field does not match. For example, a primitive form of the DECLARE command might be defined like this: ^L ; PCL.DOC.9 & SNARK:PCL.DOC.7 27-May-81 1019 PAGE 4 EXEC COMMANDS RELATING TO THE COMMAND LANGUAGE Page 1-3 COMMAND DECLARE( NOISE "for PCL"; KEYWORD (WORDS(VARIABLE:1,PCL_ROUTINES:2, TAKE_FILE:3)):OptionSelect; NOISE "Source file"; INPUTFILE:InFile); BEGIN STRING TEMP; ...etc You must use one of these two mechanisms in your command definition; if a command contains neither command arguments nor Parse statements, then PCL compiles it as if it started off with an end-of-line Parse. A Synonym is a way of making a new name for an existing command. It adds an entry to the command keyword table with the given new name as its name, which when executed runs the given old command. If, however, the new command name is a simple abbreviation of the old command name, an invisible abbreviation entry is created instead; this allows you to define, for instance, the string DI to be an abbreviation for the DIRECTORY command. 1.2 SAVE COMMAND SAVE /ENVIRONMENT (on file) filename SAVE/EXEC (on file) filename To define the entire Exec environment of variables, procedures, and commands, you may specify the ENVIRONMENT type along with the specification FileName, to load into the Exec a file previously created by the command SAVE/ENVIRONMENT. This allows a user's standard set of commands and procedures to be loaded into the Exec in internal form, without having to compile the procedures and commands again. I had originally intended that DECLARE ENVIRONMENT would completely replace the Exec's data areas; now it appears that the general desire is that it merge sets of objects. SAVE/ENVIRONMENT saves all the global variables, procedures, and user-defined commands in the file specified, in an internal format suitable for use by a later DECLARE ENVIRONMENT command. To allow for the possibility of the format of environment files changing from year to year, the file contains a version number, which must match the environment file format version number in use at the time the Declare Environment command is issued. On the installation LEVEL, a complete locally-customized Exec containing all of the installation's command definitions (commands, procedures, etc) can be produced by running a standard Exec, making the desired changes, and saving the image with the SAVE/EXEC command. This generates an EXE file which can then be placed on SYSTEM: as EXEC.EXE, ^L ; PCL.DOC.9 & SNARK:PCL.DOC.7 27-May-81 1019 PAGE 5 EXEC COMMANDS RELATING TO THE COMMAND LANGUAGE Page 1-4 so that all users automatically get that Exec when they log in. Commands so defined are regarded as "preserved" commands, which to the user are nearly part of the original system; a user can not use any command other than those defined by this local environment. Within the context of these commands, a reference to an "original" command (through DoCommand Original) obtains the original Digital command. Note that this saves the entire Exec image, containing all the defaults and variables in existence at the time of the Save command, including, for instance, the default load-class command string and the last Edit string. 1.3 UNDECLARE COMMAND UNDECLARE [switches] (from PCL) (name) name UNDECLARE (from PCL) ALL (customizations) where is COMMAND, ORIGINAL-COMMAND, PROCEDURE, SYNONYM, or VARIABLE, and the available switches are Confirm and NoConfirm. To forget the declarations of various commands, procedures, original Exec commands, synonyms, and variables, freeing the program space of commands and procedures, and removing command names from Exec's command table. Note that the Original-Command option is the only way to remove a standard Exec command; Undeclare Command is not appropriate. Undeclare ALL removes all definitions and reinitializes the Exec to its original state as much as possible. 1.4 ORIGINAL COMMAND ORIGINAL (EXEC COMMAND) command To execute a standard Exec command according to the standard definition; the text after the guide word is parsed and executed without reference to the user-defined commands. 1.5 INFORMATION VARIABLE COMMAND INFORMATION VARIABLE variable-name This prints out the current value of the global integer or string variable. ^L ; PCL.DOC.9 & SNARK:PCL.DOC.7 27-May-81 1019 PAGE 6 EXEC COMMANDS RELATING TO THE COMMAND LANGUAGE Page 1-5 1.6 INFORMATION PCL-OBJECTS COMMAND INFORMATION PCL-OBJECTS This gives a list of the commands, procedures, synonyms, and variables defined. Those which are "preserved" by being part of the installation's environment are marked with a dollar sign; those which have been superceded by user definitions are also marked with an asterisk. 1.7 SET COMMAND SET INTEGER-VARIABLE (named) variable-name (to) integer-constant SET STRING-VARIABLE (named) variable-name (to) This sets a global variable to the given value. There is a problem with COMND which currently prevents variable names used in the SET command from containing underscores. SET COMMAND-TRACE I don't know what this will do, but I'm sure it will be needed. It may just print out a trace of the DOCOMMAND statements and the program-control statements as they are executed. SET DEFAULT DECLARE /NOCONFIRM SET DEFAULT DECLARE /CONFIRM This enables or suppresses confirmation of Declare commands. INFORMATION DEFAULT DECLARE This shows the current setting of the Declare confirmation switch. ^L ; PCL.DOC.9 & SNARK:PCL.DOC.7 27-May-81 1019 PAGE 7 CHAPTER 2 THE PROGRAM LANGUAGE 2.1 PROCEDURE BNF ::= ; ::= COMMAND ::= COMMAND ( ) ::= { ; } ::= ::= : ::= ::= ::= PROCEDURE ::= PROCEDURE ( ) ::= ::= {; } I wish there was a way to say this in BNF, but there isn't: You can put in comments by starting a line with an exclamation mark. All this is as usual in a traditional language. Procedures may have parameters, which are always passed by reference, so that references to the formals within the parameter are direct references to the actual parameters. Procedures themselves may have types, which causes them to return values through the RETURN statement. You can't declare a procedure inside another declaration; all procedures are global and should be declared at the top (Exec) level. Procedures, like all other things, must be declared before they are referenced; to call one you must provide an EXTERNAL declaration. 2.2 STATEMENT BNF A lot of the language is completely traditional: ::= ::= ::= ::= ::= ::= ^L ; PCL.DOC.9 & SNARK:PCL.DOC.7 27-May-81 1019 PAGE 8 THE PROGRAM LANGUAGE Page 2-2 ::= ::= ::= ::= ::= ::= ::= ::= ::= ::= ::=