Deprecated: Implicit conversion from float-string "1573018715.771" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1573018715.771" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1573018715.771" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1573018715.771" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1573018715.771" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1573024664.954" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1573024664.954" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1573024664.954" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1573024664.954" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1573024664.954" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1575468945.113" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1575468945.113" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1575468945.113" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1575468945.113" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1575468945.113" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1605776552.304" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1605776552.304" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1605776552.304" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1605776552.304" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1605776552.304" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594
Compiler Design: LL(1) AND LALR(1)
edited by
2,517 views
8 votes
8 votes

As I know that LL(1) and LALR(1) grammars are incomperable ,but if a grammar is LL(1) then, it may be LALR(1) if the following conditions hold.

1.A ε-free LL(1) grammar is also a SLR(1) grammar and thus LALR(1) too.

2. A LL(1) grammar with symbols that have both empty and non-empty derivations is also a LALR(1) grammar.

3. A LL(1) grammar with symbols that have only the empty derivation may or may not be LALR(1).

can anyone explain each point with example. and what is this "non-empty derivation/empty derivation"?

edited by

1 Answer

4 votes
4 votes

1.A ε-free LL(1) grammar is also a SLR(1) grammar and thus LALR(1) too.

Since the grammar is LL(1), we can conclude that it is unambiguous, non-left recursive and left factored. 

Since it is unambiguous, therefore we will never reach a point while parsing where we’ll have 2 choices for reduction, therefore RR conflict of SLR(1) not possible.

Now we have to think that how will ε-free help us in avoiding SR conflict.

Since it is ε-free we’ll never reach a point where we are confused that whether we need to shift the terminal symbol or reduce ε to the non-terminal.

 

2. A LL(1) grammar with symbols that have both empty and non-empty derivations is also a LALR(1) grammar.

All logic stays the same as done in the 1st statement. Just one additional point it that here we can look ahead and make a decision whether to shift or reduce. Hence LALR(1).

 

3. A LL(1) grammar with symbols that have only the empty derivation may or may not be LALR(1).

Can anyone please give an example of such grammar. Will such grammar make any sense?

edited by

Related questions


Deprecated: Implicit conversion from float-string "1541832180.009" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1541832180.009" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1541832180.009" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1541832180.009" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1539163781.803" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1539163781.803" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1539163781.803" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1539163781.803" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803
3.2k
views
1 answers
2 votes
sripo asked Nov 10, 2018
3,191 views
Can you give an example which is not LL(1) but is CLR(1)
15.2k
views
3 answers
8 votes
Parshu gate asked Nov 13, 2017
15,210 views
Suppose we are given a grammar and asked to find the type of that grammar , what is the algorithm which needs to be followed for each of them? LL(1), OR LR(0) , OR CLR(1...
1.6k
views
1 answers
3 votes
AskHerOut asked Oct 1, 2017
1,628 views
lets consider a grammar as:$A\rightarrow Ab | Ac | a$while checking whether it belongs to LL(1) grammar, we would point out that it has a left recursion as well as left f...
888
views
1 answers
1 votes
garvit_vijai asked Oct 10, 2018
888 views
To compute FOLLOW(A) for any grammar symbol A a) We must compute FIRST of some grammar symbols.b) No need of computing FIRST of some symbols.c) Maybe compute FIRST of som...