POPPY(ID:8156/)

POP-2 for the PDP-11 


POP-2 for the DEC-11

Bill Clocksin, Edinburgh 1968


Related languages
POP-2 => POPPY   Port of

References:
  • Clocksin, Bill "Functional Specification for Poppy" Department of AI Edinburgh Uni, Scotland 1968 view details pdf Extract: Rules For Typing POPPY Text
    Rules For Typing POPPY Text

    Character Set
    The ASCII character set is used for both the internal and external representation of POPPY text.
    Letters:     Upper and lower case letters are distinguished
    Signs:     $#&*+-/   :<->?Special Signs: ^ (underline)  (backspace)
    Separator: . ;
    Comment Bracket:  |
    Bracket:  ( ) [ ]
    Decorator: %
    String Quote:  *
    Word Quote:  "¦
    Dot:  *
    End-of-File Code: ASCII code 8:032 or. 8:000
    The remaining characters are non-printing control characters. Control characters are read by character repeaters and written by character consumers, but are treated as spaces by item repeaters. Typing certain characters nay cause a mechanical action to be performed by the console (tab, newline, etc)* Such characters are unchanged from the RT-11 definitions,

    Numbers
    Only integers in the range --32768 to +32767 are supported at present. Octal numbers are denoted by prefixing 8: to the number. Octal numbers are in the range 8:0 to 8:177777,

    Words
    Words read by an item repeater may consist solely of (a) letters, digits, and special signs; or (b) signs and special signs. In (a), the first character must be a letter. In any case, special signs cannot appear as the first character of a word# Words may be of any length. Words that identify standard.variables are defined by the system in upper case letters. Words constructed by CONSWORD may contain any ASCII character,

    Strings                                                                                                  (
    Strings can be typed as any number of characters between string quotes (ASCII code 8:140), Strings may include any character. To include the string quote character in a string, two string quote characters are typed,

    Comments
    Comments consist of any number of characters between comment quotes (ASCII code 8:174). Comments are ignored by itern repeaters.. Comments are neither itemised nor interned.
    File Specifications
    A file specification is a string that specifies the name of a disc file. The string must consist of capital letters, and raay have an optional colon or dot  for specifying device names or an extension.    
    The rules for forming file specifications are identical with the RT-11 definitions. If the device name is omitted, then device DKO: is assumed. If the extension is omitted, then extension POP is assumed. Extract: Punctuation
    Punctuation
    " Word quote.
    ,; The dot is used only as an alternative notation for function application*
    ' Standard separators.
    : The colon is used for indicating a label.
    () Parentheses are as in standard  POP-2  except  that  the  form (expression)(expression) is illegal.
    (% %) Encloses the values to be partially applied.
    [] Encloses a list constant.
    [% %] Encloses a list expression.
    => The declaration arrow and print arrow are as standard POP-2 except that the print arrow lists the stack when used both at top level and when executed inside a function.
    -> The assignment arrow is as standard POP-2. Extract: Functions, Operations, and Variables
    Functions, Operations, and Variables
    In the following list, functions and operations are given with their preferred arguments. The letter i denotes anything evaluating to any type of item; n denotes an expression evaluating to an integer; f denotes an expression evaluating to a function; 1 denotes an expression evaluating to a list; s denotes an expression evaluating to a string.
    n + n
    Integer addition, an operation of precedence 5.
    n - n  and  -n
    Integer subtraction and negation, operations of  precedence 5  and 2. respectively,
    n * n                                                                                                  m
    Integer multiplication, an operation of precedence 4
    n // n
    Integer division, an operation of precedence 4, returns remainder and quotient
    i  =  i      and       i  /-   i
    Equality and  non-equality,   precedence 7
    n <  n      n >  n      n -<  n      n >= n
    Relational operators, precedence 7
    n & n
    Bitwise AND, an operation of precedence 4.  As Standard POP-2 BOOLAND.
    n I n
    Bitwise OR,  an operation of  precedence 5.     As  standard POP-2 BOOLOR.
    \  n
    Bitwise NOT, a unary operation of precedence 2* As standard POP-2 BOOLNOT.
    i ; ; i
    Infix CONS operator of precedence 2
    i <> i
    Infix list concatenation operator of precedence 2.
    ADR(i)
    A selector that returns an integer pointer to the iten (a memory address)
    i AND i
    A syntax word that may be used in any expression. Parsed as an operation of precedence 8. The expression (il AND i2) is executed in a way equivalent to: (IF il THEN i2 ELSE FALSE CLOSE).
    APPLIST(l,f)
    Applies f to each element of 1 in turn. Presently available only by compiling 'COilPAT.POP'.
    APPLY(f)
    Applies the function i.  Currenty available by compiling 'COMPAT.POP'.
    ATOM(i)
    A predicate returning 1 if i is not a pair.
    CANCEL                                                                                                                                                         ~
    Same as standard POP-2 except the following words must not be cancelled: NEUVARS_GAG, NEWVARS, ERRFUN, FREEWORD, GC_CAG, PROCLIST.
    END
    Closes a LAMBDA expression or, a function definition,
    ERASE
    Discards the top item from the user stack. Currently available only by compiling 'COMPAT.POP*
    ERRFUN(i',n).
    Calls the error routine (initialised to SYSERR) with error number n and culprit i. The system always calls SETPOP after the execution of ERRFUN, even if ERRFUN is redefined by the user but called by the system?
    EXIT
    An abbreviation of RETURN CLOSE;.  Currently available only  by compiling 'COMPAT.POP'.
    FALSE
    A standard variable with value 0*
    FNPROPS(f)
    A doublet for selecting or updating  the property component of a
    function f.
    FNTOLIST(f)
    Returns a dynamic list constructed from function f.
    FORALL
    A macro for specifying iteration. Presently available by compiling 'COMPAT.FOP'.
    FREEtfORD
    A variable whose value is the number of words of unused  free space
    since the last garbage collection.
    FROZVAL(i,f)
    A doublet for selecting or updating  the i-th frozen formal of the closure function f.
    FUNCTION
    Introduces a function definition.
    GC_GAG
    A variable which controls the printing of a message at the time of a garbage collection. Setting GC_GAG to true will inhibit printing of the message.
    GOON
    A keyword to force the compiler to exit. As in standard POP-2, except
    GOON is not needed at the end of the argument to POPVAL. GOTO
    Control passes to the label specified.
    HB(i)
    A doublet for selecting or updating the head of pair i, solidifying if j is a dynamic list*
    IDENTFN()
    The identity function of no argument and no result. Defined as:
    LAMBDA;     END;,     Available by compiling  'COMPAT.POP'.
    IDENTPROPS(w)
    A function returning an item that indicates how the word w is being used by the programmer. Same as standard POP-2# Available only by compiling  'COMPAT.POP'.
    IF
    Introduces an IF expression
    INCHARITEM(f)
    Returns an item repeater constructed from the character repeater f.
    INFILE(s)
    Returns a character repeater from the file specification s.
    ISLIST(i)
    A predicate returning 1 if and only if i is a list,  ISLIST recognises
    the null list as a list,
    ISFUNC(i)
    A predicate returning 1 only if i is a function. Also recognises closure functions.  Compile 'COMPAT.POP',
    ISNUMBER(i)
    A predicate returning  1  only  if  i  is a number.     Compile 'COMPAT.POP'.
    ISWORD(i)
    A predicate  returning  1   only  if  i   is a word.     Compile 'COMPAT.POP'.
    ITEMREADO
    The item repeater which returns the next item from PROGLIST.
    LAMBDA
    Introduces the LAMBDA expression (function literal).
    LENGTH(1)
    Returns the number of elements of list 1.
    LISTREAD()
    A repeater for returning the next list constant from PROGLIST.
    LOOPIF
    Introduces the LOOPIF expression.
    MACRESULTS(l)
    Specifies the result of a macro.
    MACRO
    Introduces a MACRO definition.  May appear in a VARS declaration.
    MAPLIST(l,f)
    Applies f  to  each member of  1,  returning  the list of results.
    Currently available only by compiling 'COMPAT.POP'.
    MEM(n)
    A doublet for accessing the PDP-11 address space. The MEM selector returns the contents of memory location n; The MEM updater updates the location. References to odd memory locations will cause a monitor trap*  References to odd device locations are legal.
    NEWSTRING(n)
    Constructs and returns a string (8-bit components) ,of length n.
    NEWVECTOR(n)
    Constructs and returns a vector (16-^bit components) of length n.
    NEWVARS_GAG
    A variable for controlling  the printing of a message whenever an undeclared variable is recognised and automatically declared by the compiler.  Setting NEWVARS_GAG to non-zero inhibits the message,
    NIL
    The atom NIL,
    NL(n)
    Prints a carriage return and n linefeed characters to the CUCHAROUT consumer,
    NONMAC
    A keyword  that  inhibits macro expansion,
    NONOP
    A keyword that inhibits parsing the next word as an operator,
    NOT 1
    A unary operation of precedence 2 that reverses the truth value of its argument. Compiling 'COflPAT.POP' changes the definition of NOT to the standard POP-2 definition,
    NULL(i)
    A predicate that returns 1 if i is the null list or null dynamic list.
    NUMBERREAD()
    A repeater that returns the next (signed) number from PROGLIST.
    OCTPR(n)
    Prints its argument as an octal number to  the CUCHAROUT device.
    Leading zeros are not suppressed. OPERATION
    Introduces an operation definition, or may appear in a VARS statement.
    i OR i
    A syntax word that may be used  in any expression.  Parsed as an ^operation of precedence 9.  The expression (il OR i2) is executed in a way equivalent to: (IF 11 THEN TRUE ELSE 12 CLOSE).
    OUTFILE(s)
    Returns a character consumer as contructed from file specification s.
    PARTAPPLY(f,i)
    Returns the closure function constructed by partially applying f to the
    arguments listed in 1. If f is a doublet, the resulting closure will, be a doublet,
    POPPIP(i1,i2)
    A function that copies the contents of character repeater il into character consumer i2. If an argument is a file specification (a string), the the file specification will be automatically converted to the appropriate consumer or repeater? Available by compiling 'COMPAT.POP'.
    POPVAL(l)
    Evaluates the POP-2 text listed in 1.  Does not require COON as the last element of 1.
    PR(i)
    Prints the item to the CUCHAROUT device in a standard form depending on the datatype of the item.
    PRSTRING(s)
    Prints the string s to the CUCHAROUT device. Omits the string quotes. Available only by compiling 'COMPAT.POP'.
    PROGLIST
    A variable whose value is FNTOLIST(INCHARITEM(CUCHARIN)).  The compiler consumes POP-2 text from PROGLIST. PROGLIST is re-initialised to the above value at each SETPOP.
    RENAME(sl,s2)
    Renames the file named si to the new name s2.
    RETURN
    A syntax word that causes an exit from its enclosing function body.
    REV(l)
    Reverses the list 1.  Available only by compiling 'COMPAT.POP'.
    SAMEDATA(i,i)
    A predicate that returns 1 if its two arguments are of the same datatype* Can be used to test items that cannot be explicitly named. The Stack Mark, the value of TERMIM, and the item indicating no culprit for an error, all are of the same datatype, which is is known only to the system.
    SETPOP()
    A function of no arguments that resets  the system by calling  the setpop state. Typing Control-G does the same thing,
    SP(n)
    Prints n spaces (ASCII code 8:040) to the CUCHAROUT device.
    SUBSCR(n,v)
    A doublet for selecting or updating the n-th component of vector v,
    SUBSTR(n,s)
    A doublet for selecting or updating the n-th component of a string.
    SYSERR
    A variable that contains the system-defined function for reporting errors, ERRFUN is initialised to the value of SYSERR*
    TERMIN
    A variable whose value is the special item indicating end-of-file. This item is not the same as the end-of-file character code,
    THEN
    Introduces the consequent of an IF expression,
    TL(1)
    A doublet for selecting or updating the tail of a list. Solidifies dynamic lists if necessary,
    TRUE
    A variable  whose value is  1,
    UNDEF
    A word indicating undefined.  The value of UNDEF is UNDEF.  All variables are initialised to UNDEF. Also initialised to UNDEF are the MEANING component of words, the FNPROPS component of functions defined by LAMBDA expressions and partial application, and probably others*
    UPDATER(f)
    A doublet  that selects or updates the  updater of a  function*
    VALOF(w)
    a doublet that selects or updates the value component of word w.
    VARS
    Introduces a variable declaration.
    External link: Online copy