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

program translation/compile rs [full grammar] a BNF grammar for the for statemen

ID: 669566 • Letter: P

Question

program translation/compilers

[full grammar] a BNF grammar for the for statement of C. Assume <expression> and <statement> and <block> are defined elsewhere nonterminals (you dont' define them). Statement is a single statement, including control statements but excluding block, and block is some code with {} around. Do not use the extended BNF notation.

For the above, write operational semantics.

Design a regular language where every sentence has to start with any number of strings 11, then repeats 100 any number of times, then repeat 00 at least once.

For the above, how many valid strings there are?

For the above, how many valid strings are there if we restrict the total length to a) at most 7 bits? b) exactly 7 bits?

Explanation / Answer

1.

We have to give full grammar or just simple grammer using the 3 given non terminala?

2.

(11)*(100)*(00)+

3.

There are infinite valid strings.

4.

If the length is limited to atmost 7 bits,

there are 7 valid strings:

(a) 00
(b) 11 00
(c) 11 11 00
(d) 11 100 00
(e) 11 00 00
(f) 100 00 00
(g) 100 00

Exactly 7, there are 2 strings:

(a) 11 100 00

(b) 100 00 00