Question: Using a following grammar and semantic rules, draw a annotated parser tree of a sentence 1 0 1 1 1 and determine what these semantic

 Using a following grammar and semantic rules, draw a annotated parser tree of a sentence 1 0 1 1 1 and determine what these semantic rules are for? 

 

A.

N -> L { N.dval = L.dval }

L -> L B { L.dval = L.dval * 2 + B.dval }

L -> B { L.dval = B.dval }

B -> 0 { B.dval = 0 }

B -> 1 { B.dval = 1 }

B.

Q 2 - Consider the following grammar,

S' S

S L = R

S R

L *R

L id

R L

The non-terminals are S', S, L, R and the terminals are =, *, id.

A) Compute the canonical collection of sets LR(1) items.

B) Construct the LR(1) and LALR(1) parsing table (action and goto)

C) Your task is to show the contents of the stack for input string *id = id using above table.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!