www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More

Question # 1:

Consider the following Grammar and remove the left-factoring from it.

A  xByA/xByAzA/a

B  b

 

Question # 2:

Consider the following CFG.

statement--> variable ASSIGNOP expr

| procedure_call

| block

| IFTOK expr THENTOK statement ELSETOK statement

| WHILETOK expr DOTOK statement

Three of the productions for statement begin with non-terminals:

variable--> ID | ID LBRK expr RBRK

procedure_call--> ID | ID LPAR expr_list RPAR

block--> BEGINTOK opt_statements ENDTOK

No remove the left factoring from the given grammar.

 

 


+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)


Views: 282

Replies to This Discussion

See the attached file for CS606 Assignment#02 Fall 2011

Attachments:

Assignment Statements:

Question # 1:

Consider the following Grammar and remove the left-factoring from it.

A  xByA/xByAzA/a

B  b

Solution

A  xA'/xA'zA/a

A'  ByA

Now

A  xA'/xA'zA/a

A  B'/B'zA/a

B' xA'


B  b

Question # 2:

Consider the following CFG.

statement--> variable ASSIGNOP expr

| procedure_call

| block

| IFTOK expr THENTOK statement ELSETOK statement

| WHILETOK expr DOTOK statement

Three of the productions for statement begin with non-terminals:

variable--> ID | ID LBRK expr RBRK

procedure_call--> ID | ID LPAR expr_list RPAR

block--> BEGINTOK opt_statements ENDTOK

No remove the left factoring from the given grammar.

Solution

In the productions for statement we replace nonterminals:

variable, procedure_call, and block, by the right-sides of their

productions to obtain:

statement--> ID ASSIGNOP expr

| ID LBRK expr RBRK ASSIGNOP expr

| ID

| ID LPAR expr_list RPAR

| BEGINTOK opt_statements ENDTOK

| IFTOK expr THENTOK statement ELSETOK statement

| WHILETOK expr DOTOK statement

Now every production for statement begins with a terminal but

four of the productions begin with the same terminal, ID, so we add a

new nonterminal, statement_rest, to the grammar and left factor ID

out of those four productions to obtain:

statement--> ID statement_rest

| BEGINTOK opt_statements ENDTOK

| IFTOK expr THENTOK statement ELSETOK statement

| WHILETOK expr DOTOK

statement statement_rest--> ASSIGNOP expr

| LBRK expr RBRK ASSIGNOP expr

| LPAR expr_list RPAR

| e

 

one more idea solution of CS606 assignment#02 fall 2011

Attachments:

RSS

Looking For Something? Search Below

Latest Activity

+ !! Ήලᵯᵯℹ Ⲥⱨ !! + replied to Ammara Sabir's discussion @@@Happy Birthday Laila@@@
7 minutes ago
+ !! Ήලᵯᵯℹ Ⲥⱨ !! + liked Mani Siddiqui Ex's discussion بھیانک کنوارے
13 minutes ago
Saqib replied to Saqib's discussion CS508 Assignment 03 Fall 2020 Solution / Discussion Due Date 29-12-2021 in the group CS508 Modern Programming Languages
13 minutes ago
+ !! Ήලᵯᵯℹ Ⲥⱨ !! + liked Ammara Sabir's discussion !!!!!^^^Islamic History^^^!!!!!!
17 minutes ago
+ !! Ήලᵯᵯℹ Ⲥⱨ !! + liked + ⵑⵑ ӍᎥŞŞ ⲤһᵘʳһშᎥⵏ ⵑⵑ +'s discussion KHATRA HY IN MN DOOB JANY KA.!!!!
17 minutes ago
+ !! Ήලᵯᵯℹ Ⲥⱨ !! + liked Ammara Sabir's discussion !!!Real Love@@@
17 minutes ago
+ M.Tariq Malik replied to + M.Tariq Malik's discussion STA301 Statistics and Probability Assignment No 03 Fall 2020 Solution & Discussion in the group STA301 Statistics and Probability
23 minutes ago
+ M.Tariq Malik replied to + M.Tariq Malik's discussion STA301 Statistics and Probability Assignment No 03 Fall 2020 Solution & Discussion in the group STA301 Statistics and Probability
27 minutes ago
≋M≋S≋ replied to + !! Ήලᵯᵯℹ Ⲥⱨ !! +'s discussion !!!! exactely!!!!
35 minutes ago
≋M≋S≋ posted a discussion
41 minutes ago
+ M.Tariq Malik replied to + M.Tariq Malik's discussion BIO201 Assignment No 02 Fall 2020 Solution / Discussion Due Date: 25-01-2021 in the group BIO201 Basic Cell Biology
43 minutes ago
+ M.Tariq Malik replied to + M.Tariq Malik's discussion BIO201 Assignment No 02 Fall 2020 Solution / Discussion Due Date: 25-01-2021 in the group BIO201 Basic Cell Biology
44 minutes ago

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service

.