Theory : First of all to construct LL(1) parser we have to know what is the First and Follow of all the each production during construction of table if we get multiple entry corresponding to a particular cell this means ambiguity and grammar can not be parse with LL(1) parser. So proceed with this problem We have to first find find "First and Follow " of production which is as follows:
Production | First | Follow |
First try and understand how first and follow is calculated for productions.First and Follow is terminal symbol which can be produced from production. We first calculate first and then follow.
FIRST: Start from symbol D, first terminal symbols we can get is
'a' and ;epsilon , it's easily observable. Let's
move to C ,here first of C will be first of symbol D , this means
'a ' will be included in the first of C but we will not get epsilon
as input in our grammar, So D will be replaced with epsilon and our
new equation will be C => Cf | epsilon. Here first of C will
first of C ,no change in our FIRST of C but C also produced
epsilon, so after replacing right hand side of C with epsilon, our
equation will be change to C=>f | epsilon, now it's similar to
same equation as D, so our first symbol of C will be {a,f,}. Similarly
for equating for B and A.
Basic rule is if first symbol is non-terminal then FIRST of that non-terminal will be included to the FIRST of symbol we are calculating and careful thing to notice is that first symbol has epsilon production. If it has then replace with it epsilon and we will get new production and kept repeating above process.
FOLLOW: Start symbol always contain $ as it follows and it similar to calculating FIRST with similar change. Here we will search same Non-Terminal symbol on right hand side of production. if exist then first symbol exactly after it will be follow of it. But here it can be non-terminal symbol also. So in that Case it will be FIRST of that non-terminal symbol which will be included as follow otherwise terminal symbol will be included. Last case can be , there is no symbol after it. So in that case FOLLOW of right hand symbol will be equal to FOLLOW of left hand symbol.
Now the construction of Parsing table with the help of FIRST and FOLLOW. Here First column is non-terminal symbol and all other are terminal symbol.
How to fill entry in the table:
Here we will see productions form which a particular symbol can be produced and we will put that particular production in that particular symbol column. For example terminal symbol 'a' is included in FIRST of all the production exist so it is putted on all column. But symbol e is produced by A=>DBCe production, so it placed on A symbol. What about epsilon symbol where does FOLLOW is used so answer is here. If some epsilon production is exists for some non-terminal symbol then it will be placed on the follow of that particular non-terminal symbol. Following these rule , our table will be constructed.
a | b | e | f | g | $ | |
A | ||||||
B | ||||||
C | ||||||
D |
But our original question was to check, whether grammar is LL(1). This is not a LL(1) grammar because as you can clearly see that many cell has contained multiple entry. It is not allowed in LL(1) grammar. It's because when our parser will be parsing string/input and a particular terminal comes and that terminal symbol contains multiple entry so parser will get confused, which production to use. It is not a LL(1) parser.
Thanks.
2A. Check if the given Grammar G is LL (1) by constructing a predictive parse table Clearly specify the different steps...
Please help me with the coding for LL(1)!!
The given grammar was:
P → PL | L
L → N; | M; | C
N → print E
M → print "W"
W → TW | ε
C → if E {P} | if E {P} else {P}
E → (EOE) | V (note: this has a variable O)
O → + | - | * V → 0 | 1 | 2 | 3 (note: this has a terminal...
(10] Eliminate left recursion from the grammar A Ba |Aa c B Bb | Ab 1 d A Ad IB A BA ASJAE Consider the following grammar G: S'S S (S)S|e fa) (10] Construct the collection of the sets of LR(0) items (b) [5] When constructing the action table of SLR parser of G what are the rules to determine the parsing actions? That is, what is the rule for a shift action at state /? What is the rule...
Analyze the given truss structure using the stiffness method.
Clearly state the steps and (matrix) equations used in the
problem-solving process.
a) Label the degrees of freedom (both free and restrained DOFs)
of the structure.
b) Determine the stiffness matrix of each element in the local
and global coordinates.
c) Assemble the structure stiffness matrix Kff
considering free DOFs, then write the complete equilibrium
equations Kff Uf = Pf and solve
for the unknown displacement vector Uf.
d) Calculate the...
Please show the steps clearly
1. A company is involved in the production of two items (X and Y). The resources need to produce X and Y are twofold, namely machine time for automatic processing and craftsman time for hand finishing. The table below gives the number of minutes required for each item: Table 1: Minutes required for each item Item Machine time Crafstman time Item X 13 20 Item Y 19 29 The company has 40 hours of machine...
Given all the information in the table, use PERT/CPM to help Mr.
Hawthorne address to the following questions.
A. Create the network diagram representing the problem.
B. What is the total time expected to be required to complete
the project if no delays occur?
C. What are the earliest and latest start and finish times for
the individual activities required to meet the expected project
completion time provided in question B (show your method for
determining this)?
D. Which are...
Question 2 For parts of the free response question that require calculations clearly show the method used and the steps involved in arriving at your answers. You must show your work to receive credit for your answer. Examples and equations may be included in your answers where appropriate Casa Intel Concentration (M) I 0.015 Samples of three gases, He(g) Is(g), and HI(g) were combined in a rigid vessel. The Initial concentrations of H2(g) and 1(9) are given in the table...
STATI501-Elementary Biological Statistics I Assignment #1 Winter 2019 Due Friday, Feb 8,2019,at the beginning of the class Instructions: . Use appropriate notations in your answers . Show all steps of your work. Otherwise. part marks will not be given. Write neat and clear (e g. big enough and less cramped up) . Answer the questions in order AND staple their pages in order . Make a photocopy of your assignment for your record. - There are 10 questions and some...
STATI501-Elementary Biological Statistics I Assignment #1 Winter 2019 Due Friday, Feb 8,2019,at the beginning of the class Instructions: . Use appropriate notations in your answers . Show all steps of your work. Otherwise. part marks will not be given. Write neat and clear (e g. big enough and less cramped up) . Answer the questions in order AND staple their pages in order . Make a photocopy of your assignment for your record. - There are 10 questions and some...
1 L, as a dynamical system (Notes from Assignment #2) We take our definition of dynamical system to be an "object" along with a specific set of modifications that can be performed (dynamically) upon this object. In this case, the object is a bi-infinite straight road with a lamp post at every street corner and a marked lamp (the position of the lamplighter). There are two possible types of modifications: the lamplighter can walk any distance in either direction from...
Refer to Table 1. Write the Excel formula for each cell marked with “?” in columns B, C and D such that formula could be copied and pasted into columns D, E, F and G using Microsoft Excel without further editing. There is no need to explicitly write the Excel formula for cells marked with “Copy & paste”. Label each formula clearly with cell reference position. In 2020, BS Bank employs 800 employees in its call centres in the United States...