Start of Interpreter for program algarv.tri at Wed May 03 16:01:25 2006
Program
#
READ n
alg:=0
IF (n<2) THEN
GOTO l6pp
alg:=1
i:=2
WHILE (i<n) DO
BEGIN
j:=i
DO
BEGIN
j:=(j+i)
IF (j=n) THEN
BEGIN
alg:=0
GOTO l6pp
END
END
WHILE (j<n)
i:=(i+1)
END
l6pp:
WRITE alg
#
Parsing tree
rootREAD | := | IF | GOTO | := | := | LOOP | label | WRITE |
|
Table of constants
Table of identifiers
i1=n | i2=alg | i3=l6pp | i4=i | i5=j |
label 'l6pp' is address of the operator {kirjutamine} (00420130)
Modified tree
rootREAD | := | IF | GOTO | := | := | LOOP | WRITE |
|
interpreting the operator READ nREAD | := | IF | GOTO | := | := | LOOP | WRITE |
Input n=5
interpreting the operator alg:=0
alg:=0
interpreting the operator (n<2)
5 < 2 ?
interpreting the operator IF (n<2) THEN
interpreting the operator alg:=1
alg:=1
interpreting the operator i:=2
i:=2
interpreting the operator (i<n)
2 < 5 ?
interpreting the operator WHILE (i<n)
interpreting the operator j:=i
j:=2
interpreting the operator (j+i)
4 = 2 + 2
interpreting the operator j:=(j+i)
j:=4
interpreting the operator (j=n)
4 = 5 ?
interpreting the operator IF (j=n) THEN interpreting the operator PLOKK
interpreting the operator (j<n)
4 < 5 ?
interpreting the operator WHILE (j<n)
interpreting the operator DO PLOKK WHILE (j<n)
interpreting the operator (j+i)
6 = 4 + 2
interpreting the operator j:=(j+i)
j:=6
interpreting the operator (j=n)
6 = 5 ?
interpreting the operator IF (j=n) THEN interpreting the operator PLOKK
interpreting the operator (j<n)
6 < 5 ?
interpreting the operator WHILE (j<n)
interpreting the operator (i+1)
3 = 2 + 1
interpreting the operator i:=(i+1)
i:=3
interpreting the operator PLOKK
interpreting the operator WHILE (i<n) DO PLOKK
interpreting the operator (i<n)
3 < 5 ?
interpreting the operator WHILE (i<n)
interpreting the operator j:=i
j:=3
interpreting the operator (j+i)
6 = 3 + 3
interpreting the operator j:=(j+i)
j:=6
interpreting the operator (j=n)
6 = 5 ?
interpreting the operator IF (j=n) THEN interpreting the operator PLOKK
interpreting the operator (j<n)
6 < 5 ?
interpreting the operator WHILE (j<n)
interpreting the operator (i+1)
4 = 3 + 1
interpreting the operator i:=(i+1)
i:=4
interpreting the operator PLOKK
interpreting the operator WHILE (i<n) DO PLOKK
interpreting the operator (i<n)
4 < 5 ?
interpreting the operator WHILE (i<n)
interpreting the operator j:=i
j:=4
interpreting the operator (j+i)
8 = 4 + 4
interpreting the operator j:=(j+i)
j:=8
interpreting the operator (j=n)
8 = 5 ?
interpreting the operator IF (j=n) THEN interpreting the operator PLOKK
interpreting the operator (j<n)
8 < 5 ?
interpreting the operator WHILE (j<n)
interpreting the operator (i+1)
5 = 4 + 1
interpreting the operator i:=(i+1)
i:=5
interpreting the operator PLOKK
interpreting the operator WHILE (i<n) DO PLOKK
interpreting the operator (i<n)
5 < 5 ?
interpreting the operator WHILE (i<n)l6pp:
interpreting the operator WRITE algOutput alg=1
program algarv.tri is completed
THE VARIABLES:
n=5
alg=1
i=5
j=8
Interpreter ended at
Wed May 03 16:01:43 2006