@V7 54 2 -5
@L5 HIUK1047
0
85  85  85  85  85  85  85  85
85  85  85  85  85  85  85  85
85  85  85  85  85  85  85  85
85  85  85  85  85  85  85  85
85  58  78  85  85  127 90  60
85  85  90  85  85  85  85  85
85  85  85  85  85  85  85  85
85  85  85  85  85  85  85  85
100 91  99  107 109 93  90  109
111 50  82  93  78  127 112 109
90  109 100 89  90  115 95  127
86  83  87  55  72  55  80  91
60  84  87  82  87  84  50  87
83  46  46  74  46  125 83  85
87  87  61  76  45  83  65  100
63  65  65  55  50  55  85  127
@L3 COUK1247
80
@V9 0
@YCHAPTER 26 - MUSS USER MANUAL
@G@RCHAPTER 26 - BASIC
@V10 1 9 355
@T% 10
@S226.1 INTRODUCTION
@BThe MUSS BASIC compiler implements BASIC as defined in the document
'Draft Proposed American National Standard for BASIC, X3J2/82-17'.
Copies of this document are available for $20 from:@
@Q 6
@
@MX3 Secreteriat
@NCBEMA
@N311First St., NW
@NSuite 500
@NWashington, DC 2001.
@
@
The compiler attempts to remain close to the standards defined, any
deviations from standard are mentioned in Section 10.3.
MUSS BASIC is available for the VAX, MC68000 and MU6G computers.
@BIn Issue 11 the compiler attempts to implement the core module as
defined in the standard (Chapter 4 through 12).  In subsequent issues
it is intended to upgrade the compiler to
implement the following modules:@
@V1 10 2 10
@
Both enhanced file modules (Chapter 11).  Graphics module
(Chapter 13).  This Chapter of the standard is under revision,
and a large number of changes are anticipated.  Thus the
revised standard is awaited before this module is implemented.@
Editing module (Chapter 16).@
@V1 0
@V2 -5
@
There are no immediate plans for the real-time and fixed decimal module.
@S226.2 COMPILER ORGANISATION
@BThe BASIC compiler compiles a complete BASIC program. The issued
BASIC compiler operates in a one pass manner to generate executable
binary as an object program or a MUSS library.  It is a
straightforward task to produce a BASIC compiler that operates
in a two pass manner, where the MUSL output from the first pass
is the input of the second pass.
@SExamples
@3
@
@
@MBASIC  SOURCE  BIN          :: One pass
@
@
@NBASIC  SOURCE  MUBLOUT      :: Two pass
@NLOAD   MUBLOUT BIN
@0
@S226.3 NON-STANDARD FEATURES
@BMUSS BASIC includes extensions to the standard which
improve efficiency on small machines by allowing a wider
range of data types.  Compiler directives are an extension
to the standardthese are described in Section 26.4.  The
formal syntax productions are given for extensions.  The
syntax productions that replace those in the standard are
highlighted with an '*'.
@S326.3.1 Standard Deficiencies in Compiler
@BThe following standard features are not implemented in Issue 11.
@T% 10
@
@
%chain-statement@
%program-name-line@
%debug-statement@
%trace-statement@
%break-statement@
%erase-statement@
%OUTIN access mode@
%SKIP REST option in read-statement and input-statement.
@S326.3.2 Character Set
@BThe definition of character is extended for tab characters.@
@
Syntax extension@
@
*unquoted-string-character=space/tab/plain-string-character@
@
Semantics@
@
A tab character is processed by the compiler as if it was a
space character.
@S326.3.3 Arithmetic Data Types
@BThe NUMERIC data type is nominally either of 32 bits or 64 bits
of real
precision.  The compiler also permits non-standard integer data
types of nominal precisions of 8, 16 and 32 bits.  Additional keywords
are as follows:@
@T% 10
@
WORD@IInteger of 16 bit nominal precision@
@
LONG@IInteger of 32 bit nominal precision@
@
INTEGER@IInteger of default precision, which is either
16 or 32 bit nominal precision@
@
REAL@ISynonym for NUMERIC.
@BThe associated extensions to the standard are:@
@
i) The declare-statement is extended to declare scalar and array
variables of the data types.
@SSyntax extension
@
@3
@Q 5
@
numeric-type > (WORD/LONG/INTEGER/REAL)@
               (numeric-identifier/numeric-array-declaration)@
               (COMMA/WORD/LONG/INTEGER/REAL)?@
               (numeric-identifier/numeric-array-declaration))*@
@0
@SExamples
@3
@
@
@MDECLARE  LONG  I,J,K
@NDECLARE  WORD  I3,AI(1 TO 20, 0 TO 3)
@NDECLARE  WORD  W1,W2,LONG L1,L2,REAL R1,R2,R3(100)
@0
@SSemantics
@BAfter a data type keyword in the declare statement all variables
are of this type until another data type keyword is encountered.
@
@
@
ii) The declare statement is extended for the type of a function to be
one of the extended numeric data types.
@SSyntax extension
@
@
*function-type = (WORD/LONG/INTEGER/REAL)?function-list@
*function-list = defined-function(comma(WORD/LONG/INTEGER/REAL)?@
                 defined-function)*@
@BA data type keyword is only permitted when the defined-function
is a numeric defined function.
@SExamples
@3
@
@
@MDECLARE  LONG  FUNCTION  LF1,LF2@
@NDECLARE  REAL  FUNCTION  RF1,RF2,WORD WF1,WF2@
@NDECLARE  FUNCTION        NUMF,STRF$@
@0
@SSemantics
@BAfter a data type keyword all functions are of that data type until
another data type keyword is encountered.
@
@
@
iii) The function-definition is extended for the type of a
function to be one of the extended numeric data types.
@SSyntax extensions
@
@
*numeric-defined-function = (WORD/LONG/INTEGER/REAL)?numeric identifier
@SExamples
@
@
@M101  DEF LONG DFL(A,B) = A**2 - B**2 + K
@N200  FUNCTION WORD (X,Y,S$,I)
@
@
@
iv) Unless a numeric identifier is explicitly declared it acquires an
implicit data type of real.  The definition of numeric identifiers is
extended for an implicit data type of integer.  The precision of
implicit integer is that of INTEGER.
@SSyntax extension
@
@
*numeric-identifier = letter identifier-character* percent-sign?
@SExamples
@
@
@MFRED%
@NInt-Sum%
@NFN.FACTORIAL%
@
@
@
v) The definition of numeric-constant is extended for integer constants.
@SSyntax extensions
@
@
*numeric-constant = sign?(numeric-rep/integer-rep)@
 integer-rep      = digit digit* percent-sign
@SExamples
@
@
@M1%
@N10234%
@SSemantics
@BInteger constants always have a percent sign.  The precision of
integer constants is INTEGER.
@S326.3.4 Line-number
@BThe definition of a line-number has been extended to five digits.
@SSyntax extension
@
@
line-number = digit digit? digit? digit? digit?
@S326.3.5 MUSS Commands
@BThe compiler is extended to allow MUSS commands to be
included in the BASIC program source for interpretation at compile
time as they are encountered.  Whenever a source program line
commences with **s the MUSS command interpreter is envoked to
interpret the command following the **.  Spaces and tab characters
may precede the **.
@SSyntax extension
@
@
@Mline > MUSS-command-line
@NMUSS-command-line = **MUSS-command
@SExamples
@
@
@M**IN SOURCEFILE
@S226.4 COMPILER DIRECTIVES
@BCompiler directives are written as a 'line' of a BASIC program.
Normally these directives may appear before or after any other line of
a BASIC source program.  Compiler directives take effect at the point
they occur during the compilation of a BASIC source program.  A directive
line does not have a line number but it may have a tail comment; all
directives start with an asterisk followed by an alphabetic letter.
@SSyntax extension
@
@
@Mline > compiler-directive-line
@BThe compiler accepts the following compiler directives as
non-standard extensions:
@
@
@M*END
@S326.4.1 *END - End of Program
@BA BASIC compilation ends when the end of the input source
document is read.  Alternatively the *END directive is used to
mark the end of the BASIC program.  This directive is needed
whenever the program is input to the compiler from a terminal
a line at a time.
@SSyntax extension
@
@
@Mcompiler-directive-line > *END tail
@SExamples
@
@
@M*END    ! End of program - nonstandard.
@S226.5 COMPILER PARAMETERS
@BThe compiler parameters where previously mentioned in Chapter 8.
@BThe first parameter specifies the origin of the BASIC source.
@BThe second parameter defines the destination of the compiler
output.
@BThe third parameter specifies the compilation options.
@BThe fourth parameter specifies the maximum number of library
interface procedures.
@S326.5.1 Compiler Options
@T% 10
@
@
Bit 0@Iindicates that debugging is not to be produced.@
@
Bit 2@Iindicates that the compilation is to produce a MUSS library.@
@
Bit 8@Iindicates that INTEGER precision is nominally 16 bits.@
@
Bit 9@Iindicates that INTEGER precision is nominally 32 bits.@
@
Bit 10@Iindicates that numeric precision of numerics is nominally
32 bits of real.@
@
Bit 11@Iindicates that numeric precision of numerics is nominally
64 bits of real.
@S226.6 IMPLEMENTATION = DEFINED FEATURES
@BThis section details the implementation defined features of MUSS
BASIC as described in Appendix 3 of the standard.  Any differences
between implementation defined features of MUSS BASIC on the VAX,
MC68000 and MU6G are also detailed.
@SSection 2.3
@
@
- interpretation of syntactically illegal constructs@
@Isyntax faults are reported to the user at compile time, and
the compiler proceeds to the next line of the source program.@
@
- format of error messages@
@IA descriptive message indicating the nature of the fault
detected is issued, and the compiler attempts to give an
indication of the position of the offending item(s) in the
source line.@
@SSection 2.4
@
@
- format of exception messages@
@IException messages are issued in one of two formats; as
illustrated in the examples below;@
@I"BASIC Exception 8002 : Too few data in input-reply"@
@I"BASIC Implementation - defined exception 7107 : Unale to open file".@
@
- hardware dependent exceptions@
@
- order of exception detection in a line@
@SSection 4.1
@
@
- other-character@
@INo other-characters are defined.@
@
- coding for the native collating sequence.@
@IThe native collating sequence is the same as the
standard collating sequence.
@SSection 4.2
@
@
- end-of-line@
@IEnd-of-line is marked by the line-feed (%A) character.@
@
- effect of parameter list in program-name-line of program@
@
- relationship of program-designators and program-name@
@SSection 5.1
@
@
- precision and range of numeric-constants@
@INumeric constants may be of the following types:@
@IINTEGER 8-bit@
@IINTEGER 16-bit@
@IINTEGER 32-bit@
@IREAL 32-bit@
@IREAL 64-bit@
@IOn all machines INTEGER8 in the range -2**{7}
to 2**7.  Similarly INTEGER16 is in the range -2**15 to
2**15.  INTEGER32 is in the range -2**31 to 2**31.@
@
@I1. MU6G@
@IOn MU6G, the default INTEGER is 32-bit.  Default REAL is REAL 32-bit
with a mantissa of 24 binary digits (approximately 7 decimal digits),
with an exponent range 16**64 to 16**(-64), which gives a maximum
decimal magnitude of 10**77 approximately.  REAL64 has an accuracy of
16 decimal digits approximately.@
@
@I2. VAX@
@IOn VAX, the default integer is 32-bit.  Default REAL is REAL 32-bit
with a mantissa of 24 binary digits (approximately 7 decimal digits), with an
exponent range 2**64 to 2**(-64) which gives a maximum decimal magnitude
of 10**19 approximately.
REAL64 has an accuracy of 16 decimal digits approximately.@
@
@I3. MOTOROLA based machines@
@IDefault INTEGER is INTEGER-16.  Default REAL is REAL-32 with a
mantissa of 24 binary digits (approximately 7 decimal digits), which
gives a maximum exponent of 10**19 approximately.  REAL64 has the
same accuracy as default REAL.
@SSection 5.2
@
@
- initial value of numeric variables@
@INo initial value is defined.
@SSection 5.3
@
@
- order of evaluation of numeric-expressions@
@IThe user should not place any reliance on the order of
evaluation.
@SSection 5.4
@
@
- accuracy of evaluation of numeric functions@
@
- pseudo-random number sequence@
@
- value of INF and EPS@
@
- availability of calender and clock@
@IBoth calender and clock are provided as part of the MUSS BASIC System.
@SSection 5.6
@
@
- precision and range of numeric values@
@IAs described in section 5.2.@
@
- precision and range of floating decimal arithmetic@
@
- precision and range of native arithmetic@
@
- accuracy of evaluation of numeric expressions@
@SSection 6.2
@
@
- maximum length of undeclared string-variables@
@IIn the current Issue, undeclared string variables may have a
maximum length of 255 characters.@
@
- initial value of string variables@
@INo initial vaue is defined.
@SSection 6.4
@
@
- values of CHR$ for the native character set@
@
- values of ORD for the native character set@
@IThe native character set is defined to be the same as the
standard character set.@
@
- availability of calender and clock@
@IBoth calender and clock are provided as part of the MUSS
BASIC System.
@SSection 6.6
@
@
- collating sequence under OPTIONS COLLATE NATIVE@
@IThis is defined to be the same as the standard collating sequence.
@SSection 7.2
@
@
- value of DET before INV has been invoked@
@INo value is defined.@
@
- value of the inverse of a singular matrix
@SSection 9.1
@
@
- value of a sdefined function when no value has been specified@
@
- initial values of local variables in external functions@
@INo initial value is defined.
@SSection 9.2
@
@
- effect of redimensioning an array parameter when an element of that@
  array is also a parameter@
@
- initial values of variables which are not formal parameters to a procedure@
@INo initial values are defined.
@SSection 9.3
@
@
- interpretation of the program-designator in a chain-statement@
@
- initial values of variables in a chained-to program@
@
- interpretation of upper- and lower-case letters in a program-designator@
@SSection 10.2
@
@
- input prompt@
@IThe default input prompt is "->".@
@
- means of requesting input in batch mode@
@IData to be supplied as input to a program to be executed
off-line should be placed immediately after the "RUN" command on the
job control stream.
@SSection 10.3
@
@
- significance width for printing numeric representations@
@I6 for REAL32 values, 12 for REAL64 values.@
@
- exrad width for printing numeric representations@
@IThe exrad width is 2 characters.@
@
- effect of non-printing characters on columnar position@
@IThe columnar position is incremented for all characters
generated during output processing.@
@
- default zonewidth@
@IThe default zonewidth is 20 character positions.@
@
- default margin@
@IThe default margin is 80 character positions.@
@
- treatment of trailing space at end of print line@
@IIf generation of a trailing space during output of a numeric
vaue would casuse the margin to be exceeded by more than one, it is
suppressed.@
@
- effect of invoking a function which cause printing while printing@
@IIf the printing is to be different channels, then the result of each
print operation is as normally defined by the Standard.  If, however,
the same channel is specified for printing, the user should place no
reliance of the format of the output generated on that channel.@
@
- use of upper or lower case "E" in exrad@
@IUpper case "E" is printed in an exrad.@
@
- attempting to reopen a file under a different ARITHMETIC option@
@
- two program-units attempting to open a file under different attributes@
  or options@
@
- means of insuring preservation of file contents between runs@
@IThis is achieved using the standard MUSS file system.@
@
- effect of certain combinations of file organisation and type@
@
- length of records in INTERNAL and NATIVE files@
@IThere is no limit placed on record length for these file
organisations.@
@
- maximum length of records when not specified or available@
@
- value of DATUM for a non-stream file@
@IThe value is "UNKNOWN".@
@
- value of ask-attribute NAME for channel zero@
@IThe value is "STR0*".
@SSection 11.0
@
@
- effect of certain combinations of file organisation and type@
@IA file name whose last character is "*" is treated as the
name of a process.
@SSection 11.1
@
@
- maximum channel number@
@IChannel numbers may be in the range 0 to 255.@
@
- whether a file name with different case letters denotes the same file@
  or different files@
@ISuch names denote different files.@
@
- effect of attempting to open an already open file@
@
- number of channels which may be active simultaneously@
@IThe maximum number is eight.@
@
- attempting to open a file with attributes different from those under@
  which it was created@
@IBASIC Exception 7106 "Incorrect type of document" is generated.@
@
- meaning of exception codes 7101-7199@
@I7101 No streams available@
@I7102@
@I7103 Illegal stream name@
@I7104 Stream undefined@
@I7105 Incorrect type of stream@
@I7106 Incorrect type of document@
@I7107 Unale tp open file@
@I7110 Illegal combination of file attributes@
@I7111 Keyed files not implemented@
@I7112 Illegal key relation@
@I7113 Incorrect mode for channel@
@I7114 Attempted use of unimplemented I/O@
@I7115 Inactive channel in RESET@
@I7116 No operation since OPEN in channel.
@SSection 11.2
@
@
- method of signifying that data is not availale for input on a@
  non-file device channel
@SSection 11.3
@
@
- means of indicating end of record (EOR)@
@IFor files with DISPLAY organisation, EOR is indicated by a newline
symbol (%A).  For INTERNAL files, EOR is indicated by a byte containing
%FF.@
@
- accuracy of printed numeric values produced by PRINT for DISPLAY files@
@IAs defined for Section 10.3.
@SSection 11.4
@
@
- retrieving a record from a NATIVE file having contents which are@
  incompatible with the TEMPLATE
@SSection 11.5
@
@
- effect of data modification statements on files that are not@
  RELATIVE or KEYED@
@
- use of SKIP in incompatible template for REWRITE
@SSection 12.1
@
@
- value of EXTYPE for locally defined exceptions
@SSection 12.2
@SSection 13.1
@SSection 13.2
@SSection 13.3
@
@
@IModule not implemented.
@SSection 14.1
@SSection 14.2
@SSection 14.3
@SSection 14.5
@SSection 14.6
@
@
@IModule not implemented.
@SSection 15.1
@
@
@IModule not implemented.
@SSection 16.0
@
@
@IModule not implemented.
@S226.7 INPUT/OUTPUT
@S226.8 MIXED LANGUAGE PROGRAMMING
@BProviding a compiler supports references to procedures in a
previously compiled library, then potentially procedures within libraries
written in any other high level language supported by MUSS may be called
from that language.  However, there are difficulties due to individual
language conventions.  To assist in mixed language usage of BASIC, the
parameter conventions of BASIC procedures will be described in terms of
the systems implementation language MUSL.
@S226.9 ERROR HANDLING
@F
