Articles on Trending Technologies

Technical articles with clear explanations and examples

Find Canonical Parsing Table (CLR) or LR (1) Parsing Table for Grammar.nS → CCnC → c C | d

Ginni
Ginni
Updated on 02-Nov-2021 8K+ Views

SolutionStep1 − Construct Augmented Grammar(0) S′ → S(1) S → CC(2) C → cC(3) C → d.Step2 − Find closure & goto to construct LR (1) itemsApplying goto on I7, I8, I9In I7, I8, I9 we have production C → d ∙, $, c → cC ∙, c | d and ∙ C → cC ∙, $ respectively, i.e., the dot cannot be shifted further.So, goto cannot be applied to I7, I8, I9.Drawing DFAFirst of all, 10 states, i.e., I0 to I9 will act as nodes for DFA.Edges are joined using goto statements. For example, goto(I0, S) = I1∴ There ...

Read More

How to find mathematical set using a data frame column in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 02-Nov-2021 173 Views

A mathematical set is a collection of unique elements or a collection of elements that are different from each other. If we want to find a mathematical set using a data frame column then we can simply use unique function.For Example, if we have a data frame called df that contains a column say X then we can find the mathematical set using X with the help of below command −unique(df$X)Example 1Following snippet creates a sample data frame −x

Read More

How to change the color of gridlines of a ggplot2 graph in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 02-Nov-2021 4K+ Views

To change the color of gridlines of a ggplot2 graph in R, we can use theme function with panel.grid.major and panel.grid.minor arguments where we can set the minor and major gridlines color of the plot panel to desired color.To understand how it can be done, check out the below Example.ExampleFollowing snippet creates a sample data frame −x

Read More

What is CLR (1) Parser?

Ginni
Ginni
Updated on 02-Nov-2021 6K+ Views

CLR defines canonical lookahead. CLR parsing use the canonical collection of LR (1) items to construct the CLR (1) parsing table. CLR (1) parsing table makes the more number of states as compare to the SLR (1) parsing. In the CLR (1), it can locate the reduce node only in the lookahead symbols.Working of CLR ParserConstruction of LR (1) collection of items for GrammarIt requires three thingsAugmented GrammarClosure Functiongoto FunctionAugmented Grammar  It is a new Grammar G′ which contains a new productionS′ → S with all other productions of given grammar G.Closureprocedure closure (I)begin Repeat for each item A → ...

Read More

How to change the plot border color of a ggplot2 graph in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 02-Nov-2021 5K+ Views

To change the plot border color of a ggplot2 graph in R, we can use theme function with panel.background argument where we can set the border of the plot panel using element_rect to desired color.To understand how it can be done, check out the below Example.ExampleFollowing snippet creates a sample data frame −x

Read More

Construct the SLR Parsing table for the following grammar. Also, Parse the input string a * b + a.

Ginni
Ginni
Updated on 02-Nov-2021 51K+ Views

Description − Consider the GrammarE → E + T|TT → TF|FF → F*|a|b.SolutionStep1 − Construct the augmented grammar and number the productions.(0) E′ → E(1) E → E + T(2) E → T(3) T → TF(4) T → F(5) F → F ∗(6) F → a(7) F → b.Step2 − Find closure & goto Functions to construct LR (0) items.Box represents the New states, and the circle represents the Repeating State.Computation of FOLLOWWe can find outFOLLOW(E) = {+, $}FOLLOW(T) = {+, a, b, $}FOLLOW(F) = {+, *, a, b, $}Parsing for Input String a * b + a −Stack    ...

Read More

Construct SLR (1) parsing table for the following grammarnS → x A y |x B y |x A znA → q s | qnB → q

Ginni
Ginni
Updated on 02-Nov-2021 4K+ Views

SolutionStep1 − Construct Augmented Grammar(0) S′ → S(1) S → x A y(2) S → x B y(3) A → q S(4) A → q(5) B → qStep2 − Find Closure & goto functions to construct LR (0) items. Here Boxes represent New States and Circles represent the repeating state.Step3 − Computation of FOLLOWS → x A yFOLLOW(S) = {$}                                                       (1)Applying Rules (2a) of FOLLOW.Comparing S → x a y with A → ...

Read More

Show that every SLR (1) is unambiguous, but some unambiguous grammars are not SLR (1). Check this for the following productions.nS → L = RnS → RnL →* RnL → idnR → L

Ginni
Ginni
Updated on 02-Nov-2021 5K+ Views

SolutionStep1 − First of all, convert it into augmented grammar G′ and number the productions(0) S′ → S(1) S → L = R(2) S → R(3) L →∗ R(4) L → id(5) R → LStep2 − Find closure and goto function to construct LR (0) items.In the following set of LR (0) items, Boxes represents the new states and circle represents Repeating statesStep3− Computation of FOLLOW− Applying Rule (1) of FOLLOW, we getFOLLOW(S) = $                                                 (1)S ...

Read More

How to create horizontal line in xyplot in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 02-Nov-2021 851 Views

To create horizontal line in xyplot, we can use abline function.For Example, if we have a data frame called df that contains two columns say X and Y and we want to create a scatterplot between X and Y using xyplot with a horizontal line at Y = 2 then we can use the command given below −xyplot(Y~X,df,abline=c(h=2))ExampleFollowing snippet creates a sample data frame −x

Read More

What is the difference between SLR, CLR, and LALR Parser in compiler design?

Ginni
Ginni
Updated on 02-Nov-2021 65K+ Views

SLR ParserSLR represents "Simple LR Parser". It is very easy and cost-effective to execute. The SLR parsing action and goto function from the deterministic finite automata that recognizes viable prefixes. It will not make specificially defined parsing action tables for all grammars but does succeed on several grammars for programming languages. Given a grammar G. It augment G to make G’, and from G’ it can construct C, the canonical collection of a set of items for G’. It can construct ACTION the parsing action function, and GOTO, the goto function, from C using the following simple LR Parsing table ...

Read More
Showing 47711–47720 of 61,297 articles
Advertisements