## Compiler – Calculation of LL (1) Grammar

I'm trying to calculate first and follow the following grammar

``````S-> ABC
A-> Aa
A-> aB
B-> Bb
B-> epsilon
C-> Cc
C-> epsilon
``````

I've calculated the first and it's all good

``````Follow (A) = {a, b, c, \$}
``````

What baffles me is the persecution of B, which I understand `Follow (B) = Follow (A)`
On the other hand, I have a solution to the grammar that says that `sequence (B) = {b, c, \$}`

So which is the right one?

## Is there an LL (K) grammar that is not a LALR (K) grammar?

It is easy to know that there are LALR (K) grammars that are not LL (K), since every left recursion grammar that is LALR (K) is not LL (K), since all LL (K ) Grammars must be recursive for free. And the opposite? Is there an LL (K) grammar that is not a LALR (K) grammar? Do you have an example?

Connected:

1. Are regular expressions \$ LR (k) \$?
2. https://stackoverflow.com/questions/14674912/why-are-there-lr0-parsers-but-not-ll0-parsers
3. https://stackoverflow.com/questions/36652221/relationship-between-lr0-ll0-lalr1-etc
Posted on Categories ArticlesTags , ,

## FOLLOW of LL (1) Grammar – Computer Science Stack Exchange

``````E -> P: P
P -> X R
R ->. P | ε
X -> num Y
Y -> num Y | ε
``````

I am looking for FIRST / FOLLOW.
First:

``````E: {num}
P: {num}
X: {num}
Y: {num, ε}
R: {., Ε}
``````

That should be fine, but I have problems with FOLLOW:

``````Q: {\$}
P: {:, ....}
R: {., ....
X: {.....
Y: {
``````

FOLLOW (F) is \$, FOLLOW (P) is because we have non-terminal P. I think we get FOLLOW (R). since there is P-> X R and the rule here is Follow (X) = First (R), so {.}. But now I'm not sure, can someone explain that?

## 16.04 – Sort order using ll

Is there a way to set the sort order of files and directories when you use the `ll` Command? I have two 16.04.5 servers with two `ext4` moves. Both drives have a folder that contains the same files. When using `ll` On both servers, the sort order is not identical (`ls -l` has the same result):

`ll` on the server a:

``````Alex.txt
iBoy.txt
Immatriculation.txt
WonderWoman.txt
``````

`ll` on server b:

``````Alex.txt
Immatriculation.txt
WonderWoman.txt
iBoy.txt
``````

The difference is the file `iBoy.txt`, Is there any way to find out why this file is not between `Alex.txt` and `Immatriculation.txt` how on the server?

## Context free – is the following grammar LL (1)

I was given the following grammar

$$S rightarrow S (S) S mid epsilon$$

First, I was asked to eliminate the left recursion. This resulted in the following:

$$S rightarrow S & # 39;$$

$$S & # 39; rightarrow (S) SS & # 39; mid epsilon$$

I was then asked if the grammar is LL (1). So I calculated the FIRST and FOLLOW sets as follows:

$$mathrm {FIRST} (S) = mathrm {FIRST} (S & # 39;) = {(, epsilon }$$,

$$mathrm {FOLLOW} (S) = mathrm {FOLLOW} (S ​​& # 39;) = { , (,) }$$,

I have now tried to build the LL (1) paring table $$M$$ as follows:

There we have production $$S rightarrow S & # 39;$$ and $$mathrm {FIRST} (S & # 39;) = {(, epsilon }$$, the entry of the table $$M [ S , ( ] = S rightarrow S & # 39;$$,

But since $$epsilon$$ belongs in $$mathrm {FIRST} (S & # 39;)$$ then for each element $$b$$ in the $$mathrm {FOLLOW} (S)$$,

$$M [ S , b ] = S rightarrow S & # 39;$$,

That would result $$M [ S , ( ] = S rightarrow S & # 39;$$,

If the entry is already filled, is this a conflict? If yes, which?

Or since the two productions are the same, can we just ignore it?

Even if the second case is the right one, is the grammar LL (1)?

## Formal Languages ​​- Why can not a left-recursive, non-deterministic or ambiguous grammar be LL (1)?

I have learned from several sources that an LL (1) grammar:

1. clearly,
2. not recursive,
3. and deterministic (left-factorised).

What I can not fully understand is why this applies to every LL (1) grammar. I know that the LL (1) parsing table has multiple entries in some cells, but I really want a formal and general (not an example) proof of the following statements:

A left-recursive (1), non-deterministic (2) or ambiguous (3) grammar is not LL (1).

Posted on Categories Articles

## Is \$ e ^ { frac { vartheta (x)} {x}} ll _ { varepsilon} x ^ { varepsilon} \$?

The question is in the title: let $$vartheta (x): = displaystyle { sum_ {p leqslant x} log p}$$ denote the first Chebyshev function.

Is it true that $$forall varepsilon> 0, e ^ { frac { vartheta (x)} {x}} ll _ { varepsilon} x ^ { varepsilon}$$?

## LL (K) -grammer generation for Postfix expressions

I have a problem with the formulation of the LL (K) grammar for this postfix expression problem (4 3/2 * 4 5 / +) as input must be issued 52/12

Posted on Categories Articles