# Tag Info

## Hot answers tagged lr-k

Accepted

### Are LR(k) languages and DCFLs equivalent?

According to Wikipedia: For every fixed $k \geq 1$: A language has an LR($k$) grammar iff it is DCFL. A language has an LR(0) grammar iff it is DCFL and has the prefix property (no word is a prefix ...
• 270k
Accepted

• 2,215

### When will SLR(1) parser fail but CLR(1) will not

No, the authors meant that there is no right-sentential form of the grammar that starts with R =. That is, the = in that ...
• 11.3k

### What is handle in bottom up LR parsing?

"When I use a word," Humpty Dumpty said, in rather a scornful tone, "it means just what I choose it to mean—neither more nor less." Charles Dodgson -- who wrote those words under ...
• 11.3k
Accepted

### Need for an augmented grammar

Yes, if you follow the canonical conversion of augmented grammars, a first step is adding a new start symbol $S'$ and the production $S' \to S$, since the algorithm may later "change" $S$. However, ...
• 20.4k
Accepted

### An intuitive explanation for LR grammars?

A language is $LR(k)$ if looking at the right side of a production, and looking $k$ symbols ahead, one can determine the left hand side of the production. This is quite incomplete, but intuitively ...
• 13.6k
Accepted

### Is THEADS the same as FIRST?

I recently had the same question in mind when reading Pager's work. I found the paper The Edge-Pushing LR(k) Algorithm by Chen and Pager, which seems to say that the two terms are indeed the same. ...
• 137
Accepted

### How to remove empty strings a.k.a (lambda, epsilon) from a LR(0) grammar

Find all nullable variables. In this case only E' is nullable. Let me illustrate the second step with an example: Replace a production A -> BCD with a family of productions like this (assuming B, C &...
• 3,419
Accepted

### Is $\{a^nb^n\}\cup\{a^nb^{2n}\}$ LR(k)?

Propbably you should read the citation as: "The problem is that the c (which separates the two parts of the language) is at the extreme right and not at the extreme left, where we start parsing." ...

### Are shift and goto moves for all LR parsers ( LR(0), SLR(1),CLR(1),LALR(1) ) same?

Every reduce action corresponds to a production; the action "undoes" the production by replacing its right-hand side with the non-terminal which produced it. That can only happen in one way; the ...
• 11.3k
Accepted

• 11.3k
1 vote

### What is the time complexity of SLR and LALR parsers?

They all run linear time with regards to input length ($O(n)$). The different algorithms have different memory trade offs for making it easier to write grammar for. That is not all grammars that work ...
• 157
1 vote
Accepted

### Reduce-reduce conflict in SLR vs LALR

Note: I'm assuming that when you wrote $SLR$ and $LALR$ that you actually meant $SLR(1)$ and $LALR(1)$. It is certainly the case that if a grammar shows a conflict in an $LALR(1)$ automaton, that ...
• 11.3k
1 vote
Accepted

### Why can't a LR(0) parser have GOTO and Reduce Items in the same canonical set?

This isn't what you asked, but let me start by saying that I suspect the answer they're looking for in the question you link is (D), "A LR(0) parser can parse any regular grammar". That ...
• 11.3k
1 vote
Accepted

### What are cases where we cannot perform LR parsing without augmented grammar?

Once we have a parsing table, we can parse (or reject) any sentence without any reference to the grammar. So at that point, the fact that the grammar was or was not augmented is essentially moot. (It ...
• 11.3k
1 vote
Accepted

### How to create a LR(k) grammar for an arbitrary k

Here's one pattern for an LR(k) grammar which is not LR(k-1). I didn't fill in the definition of $A$; there's nothing particularly special about it. It might have an empty right-hand side, or it might ...
• 11.3k
1 vote
Accepted

### Analysis of a LALR shift-reduce conflict

This conflict arises because when the parser is at the beginning of a line and the lookahead is VAR, it can't tell whether or not to reduce an empty ...
• 11.3k
1 vote
Accepted

• 19.1k
1 vote

### Use DFA minimization on LR(1) states

As shown here, minimizing the states in an LR(1) parser is NP-hard. The basic idea is that given an arbitrary graph, you can construct a grammar such that for every node in the original graph, the LR(...
• 384

Only top scored, non community-wiki answers of a minimum length are eligible