Please answer the questions below:
1. Given an example of the shortest IF statement in Modula-2.
(“Shortest” means fewest
number of lexemes.)
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) Declaration:
CONST mask = BITSET{9..11}; divisor = 512;
(b) Declaration:
PROCEDURE LessThan(addr1, addr2: ADDRESS): BOOLEAN;
VAR r1, r2: POINTER TO REAL;
BEGIN
r1 := addr1;
r2 := addr2;
RETURN r1^ < r2^
END;
(c) Statement:
LOOP
Position(pattern, source, index, found);
IF NOT found THEN EXIT END;
Delete(source, index, Length(pattern), success);
Insert(replacement, source, index, success);
IF NOT success THEN
Error("Buffer overflow in Replace");
END
END
(d) Statement:
IF queue = NIL THEN
temp^.next := temp;
temp^.previous := temp;
queue := temp
ELSE
temp^.next := queue;
temp^.previous := queue^.previous;
queue^.previous^.next := temp;
queue^.previous := temp
END
1.CONST mask=BISTE{9..11};divisor=512;
Rules:1.1 BISTE invalid keyword.It should not contain any special symbol or alphabate.
1.2: Varible length should be in 8 bytes .
1.3: Before declaring or initializing variable name declare datatype of varible.(int ,float,char,const..)
2. PROCEDURE LessThan(addr1, addr2: ADDRESS): BOOLEAN;
VAR r1, r2: POINTER TO REAL;
2.1: LessThan is name of procedure but (addr1,addr2:Address); not allowed
2.2: VAR not allowed
3. Improper parameters
Please answer the questions below: 1. Given an example of the shortest IF statement in Modula-2....
help me answer the following questions please 1. Stack (LIFO) & its application 1. Stack overflow & underflow 2. Implementation: partially filled array & linked list 3. Applications: reverse string, backtracking Exercises: 1) Which of the following applications may use a stack? A. parentheses balancing program. B. Keeping track of local variables at run time. C. Syntax analyzer for a compiler. D. All of the above. 2) Consider the usual algorithm for determining whether a sequence of parentheses is balanced....