LL(k) grammars are grammars that can be parsed from left-to-right, creating a leftmost derivation, using k tokens of lookahead.
Questions tagged [ll-grammar]
209 questions
0
votes
1 answer
Assistance swapping a grammar to LL(1)
I have the following grammar
S -> E | S A | A
E -> if (C) {S} | if (C) {S} else {S}
A -> V := T;
T -> a | b
V -> x | y
C -> V O T | T O V | V O V | T O T
O -> < | >
From this, am I correct in saying this grammar is not LL(1) because for Rule E, "if…

Kadana Kanz
- 177
- 2
- 11
0
votes
1 answer
Resolving PREDICT/PREDICT conflicts in LL(1)
I'm working on a simple LL(1) parser generator, and I've run into an issue with PREDICT/PREDICT conflicts given certain input grammars. For example, given an input grammar like:
E → E + E
| P
P → 1
I can remove out the left recursion from E,…

Minty Fresh
- 663
- 4
- 14
0
votes
1 answer
Problems about LL(1) grammar transformation
I have some problem in transforming the following non LL(1) grammar into LL(1) grammar. Is it possible to be transformed?
> A ::= B | A ; B
> B ::= C | [ A ]
> C ::= D | C , D
> D ::= x | (C)
where ;, x, (, ), [,] are terminals.

jeffi95
- 1
- 1
0
votes
1 answer
Item set and SLR(1) Questions in Compiler
I ran into a Old Exam question that solved by our TA. anyone could help me?
when we create SLR(1) about S--> aSb | a grammar, one of the item set LR(0) is like as:
{ S-->a.Sb, S-->a., S-->.aSb, S-->.a}
about extracted rule from above set, which of…
user4554402
0
votes
1 answer
How to prove that a grammar is LL(k) for k>1
I have this exercise which gives me a grammar and asks to prove that it is not an LL(1). All good with that part, though afterwards it asks me if that grammar can be an LL(k)(for k>1) or not. What procedure do I follow to determine that?

Alex
- 13
- 1
- 6
0
votes
1 answer
ANTLR failure due to left recursion. How to solve?
Here is a simple grammar for an SQL select statement
grammar SQL;
@rulecatch {
//We want to stop parsing when SyntaxException is encountered
//So we re-throw the exception
catch (SyntaxException e) {
throw e;
}
}
eval
:…

Joe
- 2,386
- 1
- 22
- 33
0
votes
1 answer
LL parser grammar
I have this grammar below and trying to figure out if can be parsed using the LL parser? If not, please explain.
S --> ab | cB
A --> b | Bb
B --> aAb | cC
C --> cA | Aba
From what I understand the intersection of the two sets must be empty to pass…

Jessica Dinh
- 11
0
votes
0 answers
Formal algorithm to rewrite a grammar that has no left-recursion and shows right precedence
Is there any formal algorithm or steps to rewrite a grammar that has no left-recursion and shows right precedence. Such as that simple algorithm for eliminating left recursion described in Wikipedia
For example, given the following algorithm:
1…

objmagic
- 1,028
- 1
- 9
- 18
0
votes
2 answers
ANTLR3 rule eval has non-LL(*) decision
Here is my grammer:
grammar esi_exp;
/* This will be the entry point of our parser. */
eval
: booleanExp
;
/* Addition and subtraction have the lowest precedence. */
booleanExp
: orExp
;
orExp
: andExpr (OR andExpr)*
…

nflearl
- 131
- 7
0
votes
2 answers
Is there a LL(*) parser that is not generated
I need to change the grammar rules of my parser at runtime and I would like to avoid regenerating the parser each time the rules changes.
Is there a parser that do not use code generation?
Regards,
0
votes
0 answers
Convert grammar to LL(1)
Got a simple grammar that have to transform to LL(1) i've tried many solutions but removed the left recursion but it does not produce the same grammar.
The grammar is this:
X -> E $
E -> E E o
E -> n
Any idea how can i turn this right recursive? Is…

Favolas
- 6,963
- 29
- 75
- 127
0
votes
1 answer
LL(1) grammar for conditional statements
I'm creating a parser for Pascal and I'm stuck at conditional statements.
Suppose I have this code snippet:
if ((10 mod 3) = 1) then ...
This is valid pascal if statement. However when I try to come up with LL(1) grammar for the ((10 mod 3) = 1)…

isklenar
- 974
- 2
- 14
- 34
0
votes
1 answer
How to adapt this LL(1) parser to a LL(k) parser?
In the appendices of the Dragon-book, a LL(1) front end was given as a example. I think it is very helpful. However, I find out that for the context free grammar below, a at least LL(2) parser was needed instead.
statement : variable ':='…

zsf222
- 345
- 1
- 10
0
votes
1 answer
Follow sets Top-Down parsing
I have a question for the Follow sets of the following rules:
L -> CL'
L' -> epsilon
| ; L
C -> id:=G
|if GC
|begin L end
I have computed that the Follow(L) is in the Follow(L'). Also Follow(L') is in the Follow(L) so they both…

user3603634
- 95
- 2
- 11
0
votes
1 answer
Can someone verify whether the following FIRST and FOLLOW sets are correct?
I am doing an exercise to create FIRST and FOLLOW sets for a grammar. I think what I did is correct but the answer is slightly different from mine. So need help from someone to verify this. Thank you.
The grammar is :
P -> L
L -> I X
X…

terk
- 15
- 4