Note: in all of the below capital letters are non-terminals, non-grammar symbols are terminals. 0. Given the following grammar, G: S → A | S # S | A @ A A → C | C A C → a | b | c For each production...

1 answer below »
how much


Note: in all of the below capital letters are non-terminals, non-grammar symbols are terminals. 0. Given the following grammar, G: S → A | S # S | A @ A A → C | C A C → a | b | c For each production below, state whether it is: In the language G decides - if so, prove it with a derviation and parse tree - if not, explain why If it is ambiguous in G - if so, prove it is with another valid parse tree in G Productions: I. a # b # c II. a @ b # c III. a @ b @ c 1. Rewrite grammar G so that: - no string in it is ambiguous - # has higher precedence than @ - # and @ are both left-associative (i.e. a # b # c should mean (a # b) # c ) 2. Given grammar H below: (in Extended BNF, terminals in bold and in red):

= [, ] ; → while() { {} }

|

→ a | b | c → 0 | 1 For each production below: - determine if it is in the language H - explain why or why not Productions: I. 0 = a,b; II. a = 0,b; III. while(a = 1,0;){b = 0;} IV. while(a) {while (a = 0;)}


Answered 4 days AfterJan 26, 2022

Answer To: Note: in all of the below capital letters are non-terminals, non-grammar symbols are terminals. 0....

Swapnil answered on Jan 29 2022
114 Votes
0
    I. a#b#c
This can basically give the production which is not belongs to G. So, in the given pro
duction the ‘#’ uses the grammar and it can be adjacent to each other that can’t be produced. So therefore the production is not belonging to the language defined by G.
II. a@b#c
The production belongs to language defined by G, the derivations are
S -> S@S -> S@S#S -> A@A#A -> C@C#C ->a@b#C
The parse tree is:
III. a@b@c
We rewrite it as
A-> S@T|T
T-> T#F|F
F->A
A->C|CA
C->a|b|c
If we can check now this grammar is basically unambiguous and # can be gives the higher precedence and @ gives the lower level of grammar.
    1
    - no string in it is ambiguous: The grammar belongs to the language that can be defined by...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here