Title says it all. I’m looking for a formal proof that there can’t be two parse trees for a same sentential form if the grammar is LR.

Can you help me?

Skip to content
# Tag: grammar

## Formal proof that if a grammar is LR then it isn’t ambiguous

## Defining a regular grammar but without $Q \rightarrow \varepsilon $

## Grammar for the following language: L = {$a^{k}$$b^{n}$$a^{m}$ : m,n,k $\in$$ N^{+}$ $\land$ m + k $\geq$ n}

## How to include both precedence and associativity in following grammar?

## There exists an algorithm to find grammar of complement of a language?

## Find equivalent LL(1) grammar

## Identify the type of the grammar

## Is following grammar LR(0)?

## Detect a class of a grammar having its DSL AST

## Developing a Context Free Grammar whilst knowing the number of terminals

100% Private Proxies – Fast, Anonymous, Quality, Unlimited USA Private Proxy!

Get your private proxies now!

Title says it all. I’m looking for a formal proof that there can’t be two parse trees for a same sentential form if the grammar is LR.

Can you help me?

I defined a regular grammar (FSM), which starts with $ ab$ and ends with $ ba$ the following way:

- $ S \rightarrow aS$
- $ S \rightarrow bS$
- $ S \rightarrow aT$
- $ T \rightarrow bR$
- $ R \rightarrow aQ$
- $ Q \rightarrow aQ$
- $ Q \rightarrow bQ$
- $ Q \rightarrow \epsilon$

, where $ S$ is the starting element, $ \epsilon$ is the empty (null) element and the rest are just variables.

The rules 6, 7 and 8 are there, so we can end a word. However, I am trying to rewrite my grammer but without the $ Q \rightarrow \epsilon$ . I can’t use the empty element.

Can it be done? I’m not sure how.

Thanks

I’m trying to create a grammar (having the highest type) for the language:

L = {$ a^{k}$ $ b^{n}$ $ a^{m}$ : m,n,k $ \in$ $ N^{+}$ $ \land$ m +k $ \geq$ n}

I’m not finding any good approach for it. Hints or ideas?

Thanks!

For the following grammar, how can I include both precedence and associativity of operators:

S -> S|S

S -> SS

S -> S*

S -> (S)

S -> a|b

**Note**: In the first rule `S -> S|S`

, the symbol `|`

is the OR symbol and not two rules.

I’m wondering if there exists an algorithm to solve the following problem:

Given a grammar $ S$ (regular, context-free, context-sensitive or irrestricted) of a language $ L$ , find a grammar $ S’$ such as $ L=L^c$ .

There is sample question to calculate equivalent LL(1) grammar for below grammar:

$ S \rightarrow S b$

$ S \rightarrow S d$

$ S \rightarrow c S$

$ S \rightarrow c c a$

At first step, it has left recursion so I remove it and convert it to bellow grammar:

$ S \rightarrow F M$

$ F \rightarrow c S$ (same as $ F \rightarrow c F M$ )

$ F \rightarrow c c a$

$ M \rightarrow \epsilon$

$ M \rightarrow b M$

$ M \rightarrow d M$

We can remove first collision of second and third part too:

$ S \rightarrow F M$

$ F \rightarrow c D$

$ D \rightarrow F M$ (same as $ D \rightarrow c D M$ )

$ D \rightarrow c a$

$ M \rightarrow \epsilon$

$ M \rightarrow b M$

$ M \rightarrow d M$

One more time remove first collision:

$ S \rightarrow F M$ (predict: c)

$ F \rightarrow c D$ (predict: c)

$ D \rightarrow c G$ (predict: c)

$ G \rightarrow D M$ (predict: c)

$ G \rightarrow a$ (predict: a)

$ M \rightarrow \epsilon$ (predict: b, d, $ )

$ M \rightarrow b M$ (predict: b)

$ M \rightarrow d M$ (predict: d)

Everything is solved except last part of grammar. I tried to solve it but I think there is no LL(1) grammar for this. Is it true? If not, Is it possible to help me? Thanks.

I have found the following question from internet. They have even given the answer as option c. But i am confused because the grammar also does not looks like a Regular. Please help me to understand this answer

I know how to verify whether grammar is LR(0) or not. But this particular case is little tricky and hence the question.

Grammar:

$ SL \rightarrow SL ; S \space | \space \epsilon$

$ S \rightarrow s$

(Note: $ SL$ is single non-terminal.)

Now, LR(0) automaton for this grammar is as follow:

Now my question is whether to consider entry $ start \rightarrow SL.$ in $ State_1$ as SR conflict.

Because I previously came to know that we don’t consider conflicts due to augmented production.

Thanks.

Let I have a grammar for some language written in some DSL for writing grammars, and this DSL implements EBNF. I have an AST for the description of a grammar in the DSL. How can I detect the minimal class of the grammar (LL(1), LL(*), LR(1), PEG, etc) without constructing tables, just analysing the AST?

I am trying to develop a CFG for the language $ L$ defined by:

$ L = \{a^{n+2}bba^{n-2} | n > 1\}$

The problem I am having is that I cannot develop the CFG for this language no matter what I try. The closest I can get is:

$ S \rightarrow aaaaXbbX$ (Production 1)

$ X \rightarrow aX | \Lambda $ (Production 2)

This *would* be right if we were somehow *forced* to substitute the same value of the non-terminal $ X$ in both its appearances in production 1. However, we can substitute $ X \rightarrow aX$ in its first apperance in production 1 and $ X \rightarrow \Lambda$ in its second appearance in production 1, thus throwing the balance of $ a’s$ off as defined in the language $ L$ .

The first question is, is there even a CFG for this?

Well, I would say according to theory, yes there is because:

- I am asked to draw a Determinate Push Down Automata for this language; and
- According to theory, every language accepted by a PDA is context-free

Am I correct that there is a CFG to this and what is it?

DreamProxies - Cheapest USA Elite Private Proxies
100 Private Proxies
200 Private Proxies
400 Private Proxies
1000 Private Proxies
2000 Private Proxies
ExtraProxies.com - Buy Cheap Private Proxies
Buy 50 Private Proxies
Buy 100 Private Proxies
Buy 200 Private Proxies
Buy 500 Private Proxies
Buy 1000 Private Proxies
Buy 2000 Private Proxies
ProxiesLive
Proxies-free.com
New Proxy Lists Every Day
Proxies123