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

Programming language concept P I truly appreciate your kind help! Please let me

ID: 643972 • Letter: P

Question

Programming language concept P

I truly appreciate your kind help! Please let me know if you need more time. Thank you in advance.

The grammar---------------------------------------------------------------

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The pairwise disjointness test is as follows: For each nonterminal, A, in the grammar that has more than one RHS, for each pair of rules, A right arrow a, and A right arrow ap, it must be true that (The intersection of the two sets, FIRST(ai) and FIRST(aj), must be empty) In other words, if a nonterminal A has more than one RIIS, the first terminal symbol that can be generated in a derivation for each of them must be unique to that RHS. Consider the following rules: The FIRST sets for the RHSs of the A-rules are {a}, {b}, and {c, d}, which are clearly disjoint. Therefore, these rules pass the pairwise disjointness test. What this means, in terms of a recursive-descent parser, is that the code of the subprogram for parsing the nonterminal A can choose which RHS it is dealing with by seeing only the first terminal symbol of input (token) that is generated by the nonterminal. Now consider the rules

Explanation / Answer

S=S1|b|ba

S1=S1ab|E

A=aa|bb|A1

A1=A1a|A1b|E