LR(k) grammars are grammars that can be parsed bottom-up from the left-to-right, producing a rightmost derivation, using k tokens of lookahead. LR(k) parsers are among the most powerful deterministic parsers available, but are often too large to use in practice.
Questions tagged [lr-grammar]
178 questions
0
votes
2 answers
How to solve this S/R conflict
Here's a simplification of my working EBNF grammar:
%token NEWLINE BLOCK_MARK A
%start file
file: block+ NEWLINE*;
block: BLOCK_MARK line;
line: A+;
Both \n and EOF spit out NEWLINE as a token (so that a single ending NEWLINE isn't required before…

kaoD
- 1,534
- 14
- 25
0
votes
1 answer
Solution in shift/reduce conflict at bison grammar
I'm trying to write a parser for tiny Visual Basic language.
And I can't resolve next shift/reduce conflict. I have these rules:
simple_type_name:
qualified_type_name
| primitive_type_name;
qualified_type_name:
ID
|…

Vladimir
- 155
- 1
- 10
0
votes
1 answer
How to use java_cup step by step?
I am totally new to java_cup and parsing and I'd like to generate parser for simple grammar using bnfc and javacup.
I've specified grammar rules and used bnfc:
bnfc -java -filename.cf
which generated me some files (i.a. filename.cup)
then I tried…

user2976158
- 1
- 1
0
votes
1 answer
LR(0) Parser conflicts
I have a doubt about lr(0) parsers.
For example I have the follow grammar:
S -> S N
|
N -> terminalsymbol
If I try to construct the first state of lr0 automaton, I get the following first state:
S ' -> . S $
S -> . S N
S -> .
So here…

Afaria
- 403
- 5
- 14
0
votes
1 answer
Shift/Reduce Conflict in Yacc/Flex
I have this grammar in yacc:
%{
#include
%}
%token texto SEP ERRO word
%start Ini
%%
Ini: Directivas SEP SEP Conceitos '$'
{ printf("Terminou bem...\n"); return 0; };
Directivas: Directiva
| Directivas SEP…

José Ricardo Ribeiro
- 709
- 9
- 23
0
votes
1 answer
Recognising LL and LR grammars... NOT parser
If I am given a CFG by looking at it can I decide whether it is a LL class of grammar or LR class of grammar? When I searched for this question on Google what I got was how the parsers for these grammars work, but, that is not what I want. Any…

Anurag Banerjee
- 19
- 1
0
votes
1 answer
Can SLR grammar have empty productions?
I've wrote following grammar:
S->S ( S ) S
S->e
e stands for "empty string"
So the language this grammar recognizes includes all strings with matching left and right parenthesis, like (), (()), (()()), etc.
And this grammar is not SLR, here is how…

wangshuaijie
- 1,821
- 3
- 21
- 37
0
votes
1 answer
What's wrong with my LR(0) grammar?
I'm trying to make my own LR(0) parser, and I'm running into trouble with some grammars.
Basically, for the grammar
exp: mexp
mexp: '1'
mexp: mexp '*' '1'
my parser is outputting
State 0: • 1
| • mexp
| • exp
| • mexp *…

user541686
- 205,094
- 128
- 528
- 886
-1
votes
1 answer
Grammar parser for parsing parliamentary debates?
I'm looking to parse the plain text from a transcription tool (the goal is to render it into LegalDocML).
My issue is that I do not know where to start and learning a grammar parser is quite a steep learning curve. I'm looking for guidance as to…

baradhili
- 514
- 1
- 7
- 27
-1
votes
1 answer
How to solve shift/reduce conflict using operator precedence?
So I have this grammar I'm trying to build an LR(1) table for
E' -> E
E -> E + E
E -> E * E
E -> ( E )
E -> a
So far, this my table
I'm trying to solve the conflicts here. I thought about changing the grammar to…

Ruba Sbeih
- 27
- 1
- 6
-1
votes
4 answers
Writing manual parser
I need write a parser manually. Can`t choose between LL(*) and LR (maybe try Earley?). Should I use bottom-up parsing, because grammar for LL will be rather difficult?

mystdeim
- 4,802
- 11
- 49
- 77
-1
votes
1 answer
Why JDT parser didn't pops elements when the state is shift-reduce?
According to A pratyical method for constructing efficient LALR(K) Parsers with Automatic Error Recovery
in chapter 4.2 .
When the parser encounters a shift-reduce , it should pops |α| elements. But the parser in JDT ,it did't pops elements. I…

kuafuking
- 89
- 6
-1
votes
1 answer
A Grammar And some challenge about SLR, LALR
I know:
A language is said to be LL(1) if it can be generated by a LL(1) grammar. It can be shown that LL(1) grammars are
not ambiguous and
not left-recursive.
but i ran into a problem.
Why the Grammar
S-> aBDb
B -> lambda
D-> dD |…
user3929084