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
0
votes
2 answers

LL grammar with associativity and self referring productions

I am trying to write a parser grammar and currently have the following productions for an LL Grammar (in Antlr) and I am trying to parse one or more (numbers or strings) that is separated by a "#" that is right associative. How do I modify the the…
rlhh
  • 893
  • 3
  • 17
  • 32
0
votes
1 answer

Antlr, rule which could result the same as another

For a compilation project, my group and me are defining a grammar with Antlr. We have currently a problem with theses rules : expr: ... | lvalue expr3 expr2 | ID '('exprList')' expr2 |... ; lvalue: ID lvalue2; lvalue2: '.' ID lvalue2 | '['…
Cédric Rémond
  • 954
  • 1
  • 8
  • 20
0
votes
0 answers

One Example about LL(1) Grammar?

I read one of my notes for Preparing PhD entrance Exam. Uppercase letter is non-terminals and Lowercase letter is terminal. We have two grammar as like : G1: S-->bSa | aSb | ba G2: S-->XYa X-->a | Yb Y--> c | epsilon My note's wrote: G1 is…
0
votes
1 answer

LL(1) parsing : end of input reached with null valued variables in stack

I am trying to understand stack operation during LL(1) parsing of an input. In an example, the input has reached the end ie. $ . Although there are some variables in my stack, they have null production rules under the $ column in my parse table. …
Flame of udun
  • 2,136
  • 7
  • 35
  • 79
0
votes
0 answers

What kind of parsing supported by ANTLR4?

I was recently using antlr4 for one of my projects. But I have no idea what kind of parsing method they are using. While i was searching some resources i found a research paper which says ANTLR4 uses a parser called ALL(*). But i have no idea about…
tnishada
  • 1,315
  • 1
  • 16
  • 24
0
votes
1 answer

How to choose which rule to use in CFG derivation?

I'm having a hard time with this textbook and my professor sees answering questions as unfair to the students who already know the material coming into the class (getting feedback from this guy is a data mining process in and of itself). Anyways, my…
0
votes
1 answer

LL(1) grammar interpretation

How do I interpret this grammar? I can't understand why some words are bold. If I was writing a parse tree/table for this, would I include the bold words? I'm trying to figure out if the grammar in the pic is LL(1), but do not understand how to…
o.o
  • 3,563
  • 9
  • 42
  • 71
0
votes
1 answer

Grammar LL(1) Dangling else and common left prefix

I believe everyone who reads it is familiar with the dangling else ambiguity. Therefore I will skip the explanation. I found on a compilers book(the dragon book) a not ambiguous grammar that represents IF and ELSE. Here it is. stmt->matched_stmt |…
Bruno Braga
  • 570
  • 2
  • 4
  • 13
0
votes
1 answer

Top down parsing - Compute FIRST and FOLLOW

Given the following grammar: S -> S + S | S S | (S) | S* | a S -> S S + | S S * | a For the life of me I can't seem to figure out how to compute the FIRST and FOLLOW for the above grammar. The recursive non-terminal of S confuses me. Does that…
xaldin
  • 23
  • 1
  • 5
0
votes
1 answer

Difference between LL parser and AST

I'm currently trying to create an LL parser. However I already have my BNF grammar but I have to create before an AST and I have a few question. What's the difference between an AST and an LL parser ? (Because both of them are a binary tree) How…
S7_0
  • 1,165
  • 3
  • 19
  • 32
0
votes
1 answer

How to read through an LL parsing ?

I read that the LL parser is a Top down parser. So logically I suppose that we read throughout from the top to the down. However, there's many way for read from the top to the down. I found on wikipedia a page which talk about the depth first which…
S7_0
  • 1,165
  • 3
  • 19
  • 32
0
votes
1 answer

Is it possible to create a LL parser using BNF grammar?

I looked on google for know if it was possible to create an LL parser using a BNF grammar but I saw on wikipedia that they use something like S → F S → ( S + F ) F → a which is not a BNF grammar. Is it possible to use BNF grammar for create an LL…
S7_0
  • 1,165
  • 3
  • 19
  • 32
0
votes
1 answer

Is This LL(1) grammar

It's really important to me, so please help me. Is this grammar LL(1)? S -> LAB L -> d | ε A -> dA | Ba B -> Bb | ε can anyone help me with LL(1) parsing table? Am I right about this? first(S) = {a,b,d} first(L) = {d} first(A) = {b,d} first(B) =…
mrp59
  • 9
  • 1
0
votes
1 answer

Parse lambda calculus style function applications with LL1 parser

I'm using TinyPG, which is an LL1 parser generator, to parse lambda calculus. I'm trying to write a rule that will parse function application like (a b) or (a b c) and so on. So far I have this rule (a bit simplified): APPLICATION -> LPARENTHESES…
Juan
  • 15,274
  • 23
  • 105
  • 187
0
votes
1 answer

Solving a first-follow conflict in a grammar

I'm currently having problems solving this kind of a conflict in a grammar: A -> (A)A' A -> 0A' A -> 1A' A'-> NAND A A' A'-> eps The problem is that FIRST of A' is NAND - as well as a part of its FOLLOW set. And since there's the A' -> eps rule,…
prkist
  • 431
  • 5
  • 13