Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use the EBNF description of the Modula-2 language below question 2 (b) to answer

ID: 3870372 • Letter: U

Question

Use the EBNF description of the Modula-2 language below question 2 (b) to answer

2. State whether or not each of the following language constructs is syntactically valid For each invalid construct, give the number of the syntax rule that is violated a) Statement REPEAT IF A[i, j] = n THEN found := TRUE; ELSE IF A [i, ] > n THEN ELSE END RETURN DEC (i) INC (j) UNTIL (i 10) (b) Declaration: PROCEDURE Sum (low, high: CARDINAL; f: Filter): CARDINAL; VAR i, sum: CARDINAL BEGIN sum := 0; FOR i := low TO high DO IF f(i) THEN sum :sumtl END END RETURN sum END Sum;

Explanation / Answer

2 (b) is not syntactically valid because it has two errors.
1) Missing ";" after "END" on line 8
2) Missing ";" after "RETURN sum" on line 10