Var 10 Plod Arrayplo Start Compilation Start Execution Begin 1 9 0 Begin 1 End 1 0 1 10 Q43828132
Homework from programming language processor class… I really needhelp… Thank you very much!
var i, a[10]; % ./plod array.plo ; start compilation ; start execution begin 1 :- 9; while i >= 0 do begin a[i] :- i. i; i:- i – 1; end; 1 :- 0; while 1 < 10 do begin write a[i]; writeln; 1 :- + 1; end; end. Figure 8: array.plo Figure 9: The output of ar- ray.plo Question 4 Answer the following questions to introduce one-dimensional array to PL/O we asume that the first element of an array has index zero and that arrays are allocated over a stack. Question 4-1 Fig.8 and Fig.9 show an extended PL/0′ program with a one-dimensional array and its output respectively. Modify your syntax diagram in Question 1 to accept the extended PL/O program, and explain the modified parts of the diagram. Hints You have to consider how to declare an array, how to refer to an array element and how to assign a value to an array element. Question 4-2 Add square brackets ( [and] ) as tokens to the PL/0′ compiler. Explain the modificaiton in your report. Hints Check an enumurated type keys in getSource.h, a structure keywd in get Source.c, and a function initCharClass in getSource.c carefully Show transcribed image text var i, a[10]; % ./plod array.plo ; start compilation ; start execution begin 1 :- 9; while i >= 0 do begin a[i] :- i. i; i:- i – 1; end; 1 :- 0; while 1
Expert Answer
Answer to var i, a[10]; % ./plod array.plo ; start compilation ; start execution begin 1 :- 9; while i >= 0 do begin a[i] :- i. i;…
OR