Answered step by step
Verified Expert Solution
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)
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started