Questions:

14. Draw parse trees for the sentences aabb and aaaabbbb, as derived from the grammar of Problem 13

15. Convert the BNF of Example 3.1 to EBNF.

16. Convert the BNF of Example 3.3 to EBNF.

17. Convert the following EBNF to BNF: S → A{bA} A → a[b]A

18. What is the difference between an intrinsic attribute and a nonintrinsic synthesized attribute?

 

Answers:

14.

Parse Tree AABB Parse Tree AAAABBBB

15.EBNF:

<program> → begin <stmt_list> end
<stmt_list> → <stmt> { ;  <stmt_list>}
<stmt> → <var> = <expression>
<var> → A | B | C
<expression> → <var> { (+|-) <var>}
16.<assign> → <id> = <expr>
<id> → A | B | C
<expr> → <expr> {(+ | *) <expr>}
| <id>
17.  S -> A | AX
X -> bA | bAX
A -> aA | abA
18. An intrinsic attribute is an inherent characteristic of a terminal symbol in the grammar. So the value of the attribute is determined solely from the terminal symbol. A nonintrinsic synthesized attribute is an attribute of a non-terminal symbol in the grammar.