LALR parsers (lookahead LR) are a family of parsers that are often used in parser generators. They provide a balance between the expressivity of LR(1) parsers and the size of LR(0) parsers.
Questions tagged [lalr]
176 questions
0
votes
2 answers
Bison shift reduce conflict on comma
I have strange shift-reduce warnings no matter what I change. Reduced grammar:
expr : NUMBER
| NUMBER ',' expr
| expr ',' NUMBER ',' NUMBER
Bison reports shift reduce on 2nd rule with comma. I tried to set precedence:
%nonassoc…

Milos Ljumovic
- 403
- 4
- 16
0
votes
2 answers
Is groff's grammar LALR(1)?
As a pet project, I'm trying to make a groff parser with Jison ( a JavaScript clone of Bison ), but I'm struggling my head trying to figure out if groff's grammar is LALR(1).
Does anyone have an insight about this?.
Thanks in advance.
Update 1
In…

roperzh
- 890
- 7
- 12
0
votes
0 answers
Cannot set precedence rules to force shift in Jison
I am trying to implement a feature in my language where you can execute a statement after returning in a function by doing return someVal then someCode().
I have the following grammar for return statements:
ReturnStatement:
'RETURN' …

Gabriel Ratener
- 595
- 5
- 20
0
votes
1 answer
Trying to Resolve Shift Reduce Conflicts by Changing Grammar
Given the following specification for a grammar:
Statement → { Statement* }
→ VarDecl
→ if ( Exp ) Statement else Statement
→ while ( Exp ) Statement
→ System.out.println ( Exp ) ;
→ id = Exp ;
→ id [ Exp ]= Exp…

user2116243
- 303
- 2
- 10
0
votes
1 answer
Bison - when is %prec really needed for unary operators?
I am currently playing with Flex and Bison for a first time. I have read about contextual precedence on Bison manual page. Tried to build a minimal example without using %prec directive as I am not that familiar with what it really does. Here is my…

Marek Milkovič
- 464
- 1
- 8
- 20
0
votes
1 answer
Using midaction rules in Lemon to interpret "let" expression
I'm trying to write a "toy" interpreter using Flex + Lemon that supports a very basic "let" syntax where a variable X is temporarily bound to an expression. For example, "letx 3 + 4 in x + 8" should evaluate to 15.
In essence, what I'd "like" the…

Martin Galese
- 3
- 1
0
votes
1 answer
Shift/reduce conflict with infix sections
I'm having trouble with a yacc-like implementation (using ocamlyacc, in particular) of a grammar that includes ordinary infix operations plus infix sections, like in Haskell. I desire all of these to be grammatical:
(+1)
(1+)
(+)
(1+1)
However, I…

dubiousjim
- 4,722
- 1
- 36
- 34
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
Parsing an indentation-based syntax (like Python) with YECC
I have the following piece of code:
case 1
of 2
3
of 3
4
5
That my custom tokenizer translates to:
Tokens: [{'case',1},
{integer,1,1},
{eol,1},
{'of',1},
{integer,1,2},
{block,[{integer,1,3}]},
…

caio
- 1,949
- 16
- 20
0
votes
1 answer
LALR parsers and look-ahead
I'm implementing the automatic construction of an LALR parse table for no reason at all. There are two flavors of this parser, LALR(0) and LALR(1), where the number signifies the amount of look-ahead.
I have gotten myself confused on what look-ahead…

Tony Ennis
- 12,000
- 7
- 52
- 73
0
votes
1 answer
C99 grammar in Irony - declaration/statement conflicts
I'm trying to use Irony to parse C99, and I found a grammar online to guide me.
I'm having difficulty with conflicts on declaration versus statement. The following rule fails to detect a pointer declaration with initializer.
blockItemList.Rule =…

xtravar
- 1,321
- 11
- 24
0
votes
1 answer
Solve ambiguity in my grammar with LALR parser
I'm using whittle to parse a grammar, but I'm running into the classical LALR ambiguity problem. My grammar looks like this (simplified):
::= '{' '}' # string enclosed in braces
::= '[' ']' #…

tobiasvl
- 570
- 4
- 20
0
votes
1 answer
Calculating FOLLOW() or propagate?
I am a little confused regarding the lookaheads computation for LALR(1) parsers.
In the book "Parsing Techniques - A Practical Guide" they state that propagating lookaheads (+ spontaneous generated lookaheads) is equivalent to calculating the…

ilomambo
- 8,290
- 12
- 57
- 106
0
votes
2 answers
Issues with Erlang's Yecc precedences
I’m trying to write an Erlang parser with Yecc, but I’m having some troubles with the precedence of the semantic rules. In my case I defined the grammar, the terminal and non-terminal symbols, the rules and the associated code.
This is what I wrote…

ccamacho
- 707
- 8
- 22
0
votes
1 answer
Shift/reduce conflict byaccj
I am encountering a shift/reduce conflict inside this trivial Regular Expression parser. I am a beginner in yacc and I seem to be a little confused. Here is what I have written so far:
%token ID
%%
exp: ID { $$ = new…

Gog
- 17
- 1
- 5