
        A Language With A List Data Type


The following syntax adds a list data type to Language-14.

       Prog ::= '(' 'prog' Body ')'

       Body ::= Exp+

        Exp ::= Begin | Var | NExp

      Begin ::= '(' 'begin' Body ')'

        Var ::= '(' 'var' VARIABLE NExp ')'

       NExp ::= Set | If | While | And | Or
              | Apply | VARIABLE
              | Lambda | INTEGER | BOOLEAN | List | Symbol

        Set ::= '(' 'set' VARIABLE NExp ')'

         If ::= '(' 'if' NExp Exp Exp ')'

      While ::= '(' 'while' NExp Exp ')'

        And ::= '(' '&&' NExp NExp NExp* ')'

         Or ::= '(' '||' NExp NExp NExp* ')'

      Apply ::= '(' NExp NExp* ')'     // function "name" followed by actual parameters

     Lambda ::= '(' 'lambda' VARIABLE* Exp ')'  // formal parameters followed by the body

       List ::= '(' 'list' NExp* ')'   // List doesn't evaluate "symbols"

     Symbol ::= '(' 'sym' SYMBOL ')'

     SYMBOL ::= [a-zA-Z][a-zA-Z0-9]*
   VARIABLE ::= [a-zA-Z][a-zA-Z0-9]*
    INTEGER ::= [0-9]+
    BOOLEAN ::= 'true' | 'false'

This language should also include the following built-in functions.

   'car' Returns the first item from its list parameter
   'cdr' Returns the list formed by removing the first item from its parameter
  'cons' "Constructs" a list by prepending its 1st parameter to its 2nd parameter
'empty?' Returns true if its parameter is an empty list
     '+' Addition of one, or more, integer operands
     '-' Unary negation of an integer operand
     '-' Subtraction of two integer operands
     '*' Multiplication of two, or more, integer operands
     '/' Division of two integer operands
     '%' Remainder of two integer operands
     '^' Exponentiation of two integer operands
     '!' Unary negation of a boolean operand
    '==' Equality of two operands
    '!=' Inequality of two operands
     '<' Less than
     '>' Greater than
    '<=' Less than or equal
    '>=' Greater than or equal
 'print' Print one operand


The lists in this language are, like Lisp and Scheme, "symbolic lists". That means that variables in a list are considered "symbols" and are not evaluated.