Questions tagged [ll-grammar]

LL(k) grammars are grammars that can be parsed from left-to-right, creating a leftmost derivation, using k tokens of lookahead.

209 questions
5
votes
1 answer

Top-Down Parser want to have decent case example left-recursion in a 'Code'

Hello fellow stack over flow members. I'm studying for compiler class. I did understand Top-Down Parser should avoid left-recursion, and transform into right-recursion way. Questions are, a) am I understanding right Top-Down Parser is equal to LL…
5
votes
3 answers

What are FIRST and FOLLOW sets used for in parsing?

What are FIRST and FOLLOW sets? What are they used for in parsing? Are they used for top-down or bottom-up parsers? Can anyone explain me FIRST and FOLLOW SETS for the following set of grammar rules: E := E+T | T T := T*V | T V :=
user460920
  • 887
  • 5
  • 17
  • 27
5
votes
1 answer

Is every LL(1) grammar also an LR(0) grammar?

I know that every LL(1) is also an LR(1). But what about the relationship between LL(1) and LR(0), can a LL(1) be a LR(0) as well?
bopia
  • 59
  • 1
  • 6
5
votes
2 answers

Ebnf – Is this an LL(1) grammar?

I found the following EBNF on wikipedia, describing EBNF: letter = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" ; digit = "0" | "1"…
tilpner
  • 4,351
  • 2
  • 22
  • 45
4
votes
2 answers

Assignment as expression in Antlr grammar

I'm trying to extend the grammar of the Tiny Language to treat assignment as expression. Thus it would be valid to write a = b = 1; // -> a = (b = 1) a = 2 * (b = 1); // contrived but valid a = 1 = 2; // invalid Assignment differs from other…
Adam Schmideg
  • 10,590
  • 10
  • 53
  • 83
4
votes
1 answer

How to eliminate this Left Recursion for LL Parser

How do you eliminate a left recursion of the following type. I can't seem to be able to apply the general rule on this particular one. A -> A | a | b By using the elimination rule you get: A -> aA' | bA' A' -> A' | epsilon Which still has left…
4
votes
1 answer

Left-factoring a grammar

So i have this grammar (below) and i need to build a parse table. I need to make this suitable for a predictive parser. I know the first think is to make it unambiguous, but for me it's already unambiguous (since i can't find a string for which i…
4
votes
1 answer

Does there exist an LR(k) grammar with no LL(1) equivalent

I haven't been able to find an answer to this yet. Are there grammars that are context free and non-ambiguous that can't be converted to LL(1)? I found one production that I couldn't figure out how to convert into LL(1): the parameter-type-list…
4
votes
2 answers

can removing left recursion introduce ambiguity?

Let's assume we have the following CFG G: A -> A b A A -> a Which should produce the strings a, aba, ababa, abababa, and so on. Now I want to remove the left recursion to make it suitable for predictive parsing. The dragon book gives the following…
4
votes
1 answer

Parse function call with PyParsing

I'm trying to parse a simple language. The trouble comes with parsing function calls. I'm trying to tell it that a function call is an expression followed by left parenthesis, argument list, and right parenthesis. I have something like this: expr =…
kirbyfan64sos
  • 10,377
  • 6
  • 54
  • 75
4
votes
1 answer

LL-1 Parsers: Is the FOLLOW-Set really necessary?

as far as I understand the FOLLOW-Set is there to tell me at the first possible moment if there is an error in the input stream. Is that right? Because otherwise I'm wondering what you actually need it for. Consider you're parser has a non-terminal…
ben
  • 5,671
  • 4
  • 27
  • 55
3
votes
1 answer

Parsec: Predictive parsing

I have only a few skills with haskell and I need help how to implement predictive parsing (LL*) with parsec. I have context free grammar: ::= identifier | identifier '(' ')' Based on…
312k1t
  • 269
  • 1
  • 4
  • 10
3
votes
2 answers

Parsing the Context-free-Grammars

I know that a bottom-up parser is better than a top-down parser because it can accept left-recursive grammar, what can be other reasons that we prefer bottom-up parsing over top-down parsing?
Amna Ahmed
  • 1,944
  • 4
  • 20
  • 25
3
votes
2 answers

J programming language (E)BNF

I'm writing a paper for my Programming Languages and Compilers course about the J programming language. Since it's a relatively unknown (but interesting) programming language, I'm having trouble finding the right documentation and information…
empa
  • 53
  • 4
3
votes
1 answer

ANTLR4 grammar integration complexities for selection with removals

I’m attempting to create a grammar for a lighting control system and I make good progress when testing with the tree gui tool but it all seems to fall apart when I attempt to implement it into my app. The basic structure of the language is [Source]…
Mike James
  • 461
  • 2
  • 4
  • 20
1 2
3
13 14