Questions tagged [ll-k]
20 questions
13
votes
2 answers
Is there any way to distinguish between LL(k) and LR(k) grammar?
I am recently studying about Compilers designing. I came to know about two types of grammar one is LL grammar and other is LR grammar.
We also know the facts that every LL grammar is LR that is LL grammar is a proper subset of LR grammar. First one…
Debabratta Jena
- 359
- 1
- 3
- 9
3
votes
1 answer
How to generate an LL(2) parse table?
The algorithms I've seen for building an LL(1) parse table involve calculating first and follow sets such that:
predict(nonterminal, production) ==
if epsilon in FIRST(production):
first(production) union follow(nonterminal)
…
Max Heiber
- 378
- 2
- 12
3
votes
1 answer
Lookahead set: Determining minimum $k$ such that $G$ is a strong $LL(k)$ grammar
How do we determine minimum $k$ such that $G$ is a strong $LL(k)$ Grammar
Like for grammar $G$ with the following rules
$S\rightarrow aAcaa \mid bAbcc,A\rightarrow a \mid ab \mid \epsilon$
Iancovici
- 675
- 3
- 14
- 26
2
votes
1 answer
Lookahead in LL(k) parsing
I'm having difficulty understanding what lookahead is $\mathrm{LL}(k)$ parsing. Does $k$ lookahead mean I consume $k$ symbols at a time and then process them?
Any help is appreciated.
flashburn
- 1,233
- 1
- 12
- 22
2
votes
1 answer
Not respecting the 3rd rule of a LL(1) grammar
I'm trying to build a grammar that violate only the 3rd rule. I'm trying to figure out what kind of grammar would not respect that.
I think the grammar has to be left-recursive to not respect it.
if $\beta \Rightarrow^* \epsilon$ then $\alpha$ does…
Laura
- 21
- 2
2
votes
1 answer
How to treat $\epsilon$ and '$' in top-down predictive parsing (predict table)?
How to treat $\epsilon$ and '\$' in top-down parser using predict table?
The construction of the predict table
Given a product $X \rightarrow w$, row $X$ and column $t$
-Mark $X \rightarrow w$ for each $t \in FIRST(w)$
-If $NULLABLE(w)$, then…
mavavilj
- 579
- 7
- 23
2
votes
2 answers
Arguing that $L= \{a^n | n\geq 0\} \cup \{a^nb^n| n\geq 0\}$ is not $LL(k)$ for any $k$
Consider the language $L= \{a^n \mid n\geq 0\} \cup \{a^nb^n\mid n\geq 0\}$ and the following statements.
$\quad\quad\text{I. }L$ is deterministic context-free.
$\quad\quad\text{II. }L$ is context-free but not deterministic…
Abhishek Ghosh
- 1,184
- 9
- 24
2
votes
1 answer
Is this a proper LL(1) Grammar?
Please take this question with a grain of salt. I'm trying to write a very simple layout engine and wanted to formally create a grammar to parse the input. I stayed up all night researching LL(k) parsers - mostly from papers from different colleges.…
iwannawriteacompiler
- 205
- 2
- 7
1
vote
1 answer
Proof that the grammar is LL(2)
I am given the following grammar:
$
S \rightarrow AabAba
\\
A \rightarrow a | \epsilon
$
and I have to prove it is LL(2).
I know what LL(k) means - one can choose a production based on k characters from the input.
So consider the input $ababa$. Of…
user84912
1
vote
1 answer
Can I mix LL and LR parsing?
I want to go RD parsing with Shunting Yard for expression (for the sake of easier operator precedences and less left-recusion), is that considered no-good because nobody did that before?
Steve Fan
- 121
- 4
1
vote
1 answer
Conditions for LL(1) grammar
One of the conditions for A → α | β to be LL(1) grammar states that
If β → ε in one or more steps then α doesn't derive any string beginning with a terminal in FOLLOW(A). Likewise If α → ε in one or more steps then β doesn't derive any string…
jblixr
- 111
- 1
- 3
1
vote
1 answer
How to treat ϵ-productions in table-driven predictive parsing?
Here:
https://www.cs.rochester.edu/~nelson/courses/csc_173/grammars/parsing.html
in chapter Driver Procedure, it's shown how table-drive predictive parsing works.
The predict table however can involve $\epsilon$-productions (which leads to including…
mavavilj
- 579
- 7
- 23
1
vote
1 answer
What exactly is the LL(k) grammar condition?
I have a bit of trouble understanding the definition of LL(k) grammars.
Here it's defined as:
for every pair of production rules
$A\rightarrow
α$
and
$A \rightarrow
β$
the following condition holds.
$\text{FIRST}_k$
(
$\text{α…
mavavilj
- 579
- 7
- 23
1
vote
2 answers
Can an LL(k) parser parse any grammar without left recursion or common prefixes?
I'm being asked to create a "top down grammar" for a certain language (I'm pretty sure there's no such thing as a "top down grammar" but I think it means write a grammar that an LL(k) parser can parse).
I'm pretty sure the language is not LL(1), but…
Aurast
0
votes
0 answers
Proof of every regular language has a LL(1) grammar
I tried some examples and found that LL(1) grammar always exist.
I tried searching for formal proof but didn't find any.
Can someone give a formal proof for the above statement?
Noob
- 1