Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Consider the grammar in Figure 1, which you have seen in Assignment 4: (a) (10 marks] Construct the FIRST table for this grammar. (b)

image text in transcribedimage text in transcribed

1. Consider the grammar in Figure 1, which you have seen in Assignment 4: (a) (10 marks] Construct the FIRST table for this grammar. (b) (10 marks] Construct the FOLLOW table for this grammar. (c) (10 marks] Construct the PREDICT table for this grammar. (d) (10 marks] Modify the grammar so that it is LL(1). E Method Decl + 'def' id '(' ParamList ')' Block ParamList + c ParamList Param ParamList Tail ParamList Tail ParamList Tail + Param ParamList Tail Param id Block + '{' Statements '}' Statements Statements + Statement Statements Statement + IfStatement Statement + ReturnStatement IfStatement + 'if''('Erpression ')' Block Else Else + Else + 'else Block Else + 'else' IfStatement ReturnStatement + 'return' Expression Expression + integer Expression id Expression + id '('ArgList')' ArgList ArgList + Expression Arg List Tail Arg List Tail ArgList Tail + Arg ArgList Tail Arg + Expression E Figure 1: A Grammar for function definitions. 1. Consider the grammar in Figure 1, which you have seen in Assignment 4: (a) (10 marks] Construct the FIRST table for this grammar. (b) (10 marks] Construct the FOLLOW table for this grammar. (c) (10 marks] Construct the PREDICT table for this grammar. (d) (10 marks] Modify the grammar so that it is LL(1). E Method Decl + 'def' id '(' ParamList ')' Block ParamList + c ParamList Param ParamList Tail ParamList Tail ParamList Tail + Param ParamList Tail Param id Block + '{' Statements '}' Statements Statements + Statement Statements Statement + IfStatement Statement + ReturnStatement IfStatement + 'if''('Erpression ')' Block Else Else + Else + 'else Block Else + 'else' IfStatement ReturnStatement + 'return' Expression Expression + integer Expression id Expression + id '('ArgList')' ArgList ArgList + Expression Arg List Tail Arg List Tail ArgList Tail + Arg ArgList Tail Arg + Expression E Figure 1: A Grammar for function definitions

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Insiders Guide To Dol Plan Audits How To Survive An Employee Benefit Plan Audit

Authors: Frank J. Bitzer, Jr. Ferrigno, Nicholas W.

1st Edition

0872182711, 978-0872182714

More Books

Students also viewed these Accounting questions