] > L756 Language Manual

L756 Language Manual

  General Description
  Available Features
• Numbers • Variables/Labels • Arithmetic Expressions • Assignment Statements • GOTO Statements • Conditional Statements • FOR Statements • Input/Output Statements • END Statements • Comments
  The Syntax of the L756 Language

General Description

An L756 program is a sequence of (possibly labeled) statements. Normally, statements are executed in their order of appearance in the sequence unless a transfer of control is specified by a GOTO statement, an IF statement, or a FOR statement.

Any number of blanks can appear between adjacent tokens, and no blank may separate adjacent characters of a token. Line break characters are treated as space characters.

Example.
        X = 12  
        IF X > 10 THEN GOTO L30  
        x=3  
        IF X<10 THEN GOTO L30  
   L30: END 

Available Features

The following are the features of L756.

Numbers

A number is a sequence of decimal digits such as: 1235 and 22

Variables/Labels

A variable is denoted by a string of letters and digits whose first character is a letter. Strings which agree on their first seven characters are assumed to denote the same variable. Labels are similarly defined but they must be followed by ”:”.

Example. I, I1AB3, and Z9:

Each variable must be defined at the start of the program using a DCL instruction of the form ‘DCL <id>’.

Arithmetic Expressions

Arithmetic expressions are formulas for computing a value. They are made up using ṉumbers, variables, the four arithmetic operators +, -, *, /, and the left and right parentheses.

Example. (of general expressions)
   A1 + B * (C + D * (C + E))  
   A1 + 3114159 / 4 * (C + 12)

The order in which operations are performed is normally from left to right except that

Example. (order of operations is indicated below the expression)
  A  + (B /(C  + D))  * (F  * G  * (H  + B))  + C  
     7    2    1      6     3    5     4     8 

Assignment Statements

The general form of an Assignment statement is

   LET <variable> = <arithmetic expression>

The value of the arithmetic expression is computed and assigned to the variable.

Example. : LET X1 = y1 + 1206 * Z + XL
GOTO Statements

The general form of a GOTO statement is ‘GOTO <id>’. Control is transferred to the statement with the specified label.

Example. : GOTO L5
Conditional Statements

The general form of a Conditional Statement is:

   IF <arithmetic expression><relational operator>  
      <arithmetic expression> THEN GOTO <label>

where the relational operators are =, <>, <, <=, >, and >=.

If the relation holds between the values of the two arithmetic expressions then the control is transferred to the specified label. Otherwise, control passes to the code that appear after the instruction.

    IF X > y THEN GOTO L2  
    IF Z + (X*y) = X1 + 12i THEN GOTO L5 

FOR Statements

FOR statements are used to set up program loops. There are two general forms of FOR Statements:

   FOR <variable> = <arithmetic expression 1>  
       STEP<arithmetic expression 3> TO  
           <arithmetic expression 2>  
   DO ... statements ... NEXT  
 
   FOR <variable> = <arithmetic expression 1> TO  
           <arithmetic expression 2>  
   DO ... statements ... NEXT         

The second form is interpreted in the same way as the first except that all the step size (arithmetic expression 3) is assumed equal to 1. The FOR statement forms the entrance of a program loop that continues through any number of subsequent statements until a NEXT to close the loop is reached.

Example.
   FOR X = 1 STEP 5 TO 100 DO  
       LET W = X + y + Z  
       LET Z = X * y  
   NEXT 

Informally, the statements in the loop between the FOR and the NEXT are executed over and over again a number of times as specified by the FOR statement. Each time around the loop the value of the variable is incremented by the step and compared with the final value to determine whether to enter the loop again or to terminate the FOR statement.

Specifically, the execution of the FOR Statement is as follows:

Input/Output Statements
    READ  <identifier>  
    WRITE <expression> 

END Statements

Every program must have a single END statement – the last (highest-numbered) statement in the program.

Comments

Comments can be added to a program using the REM statement, the general form of which is

   REM <any sequence of characters but;>;

The compiler ignores the input stream between (and including) the REM and its first following semicolon.

The Syntax of the L756 Language

1.<program> <dcl> <body> END
2.<dcl> DCL <id> <dcl>
3. ϵ
4.<body> <stat> <body>
5. ϵ
6.<stat> <stat1>
7. <label> <stat1>
8.<label> <id> :
9.<stat1> LET <id> = <expr>
10. GOTO <id>
11. IF <expr> <relop> <expr> THEN GOTO <id>
12. <for> <body> NEXT
13. READ <id>
14. WRITE <expr>
15.<for> FOR <id> = <expr> <step> TO <expr> DO
16.<step> STEP <expr>
17. ϵ
18.<relop> <relop1>
19. =
20.<expr> <expr1>
21.<expr1> <expr1> <+-> <term>
22. <term>
23.<term> <term> <*/> <oprnd>
24. <oprnd>
25.<oprnd> <number>
26. <id>
27. ( <expr1> )

Note: <relop1 > stands for the class of relation operations: >,<,<>,>=,<= .