Questions tagged [shift-reduce-conflict]

Shift Reduce is an LR parser paradigm. A shift/reduce conflict occurs when there is ambiguity in the grammar being parsed.

When parsing using an LALR parser a stack is maintained of the tokens that have been seen, then given what is on input and what is on the stack, either the next token is shifted onto the stack or a production is made and the necessary tokens are popped off the stack and reduced to the appropriate production. A shift reduce conflict occurs when given the tokens on the stack and given the input, both a shift and a reduce action should occur according to the grammar.

This ambiguity is often mitigated through the use of precedence instructions to the parser.

167 questions
0
votes
1 answer

Where is the shift/reduce conflict in this grammar?

Can't seem to figure out what's causing the shift/reduce conflict in this grammar. It seems to be fixed with assigning rightmost operator precedence to CMD and LCURLY, yet I do not know exactly what the problem is. Any help? ContentList : Content …
thomasskov
  • 188
  • 1
  • 7
0
votes
1 answer

Bison: Fixed shift/reduce errors, no clue how

So I was having the dreaded shift/reduce errors with my grammar. Here's a minimal test case: %token PLUS MINUS TIMES DIVIDE NUMBER %token EQUAL NEQUAL GREATER LESS NOT %left EQUAL NEQUAL %left GREATER LESS %left PLUS MINUS %left TIMES …
Bram Speeckaert
  • 100
  • 1
  • 5
0
votes
2 answers

Resolve Shift/Reduce warning in GnuWin32 Bison?

i have the following rules and when implementing them with bison i get 5 shift/reduce warnings. a part of the Rules are: Type----> BOOL | INT | CHAR | DOUBLE | ID | INT '['']' ; rule: VarDec…
0
votes
1 answer

shift/reduce conflict in cup parser (grammar with arrarys and matrices)

I am writing a cup parser for a small language that is supposed to support classes with arrays and matrices as its fields. For example, if there is a class instance: C c; the fields are to be accessed with: c.x; c.y[]; c.z[][]; I am having trouble…
0
votes
2 answers

Where is this shift/reduce conflict coming from in Bison?

I am trying to get the hang of parsing by defining a very simple language in Jison (a javascript parser). It accepts the same / very similar syntax to bison. Here is my grammar: %token INT TRUE FALSE WHILE DO IF THEN ELSE LOCATION ASSIGN EOF…
user2269972
  • 31
  • 1
  • 2
0
votes
1 answer

Where are the shift/reduce conflicts in this Bison code?

I have a Shit/reduce conflicts in my bison code : expression : LBRACKET expression RBRACKET {$$ = $2;} | fct_call {} | operand {} | expression operator_arith expression …
DouglasAdams
  • 490
  • 7
  • 19
0
votes
1 answer

Date Time Parser using YACC shift reduce conflicts

I have the following YACC parser %start Start %token _DTP_LONG // Any number; Max upto 4 Digits. %token _DTP_SDF // 17 Digit number indicating SDF format of Date Time %token _DTP_EOS …
manu_dilip_shah
  • 880
  • 14
  • 32
0
votes
1 answer

Precedence conflict with postfix/infix operators

Here is a grammar wrote for the lemon parser generator : %left PostDecrementation. %right PreDecrementation. program ::= expression. expression ::= Terminal. expression ::= unaryoperation. unaryoperation ::= Decrementation expression.…
Maël Nison
  • 7,055
  • 7
  • 46
  • 77
0
votes
1 answer

Parser issues, looking for the end of a parameter, shift/reduce conflicts occurring

I'm trying to set up my parser to find the end of a certain parameter by recognizing that there isn't a comma, so I basically have it set up to find a parameter like this parameter: end_parameter comma (This data type is just a list, so there isn't…
0
votes
1 answer

Shift/reduce conflict with expression call

When I'm trying to compile this simple parser using Lemon, I get a conflict but I can't see which rule is wrong. The conflict disappear if I remove the binaryexpression or the callexpression. %left Add. program ::= expression. expression ::=…
Maël Nison
  • 7,055
  • 7
  • 46
  • 77
0
votes
1 answer

yacc shift/reduce conflict. It really serious complexity

I was trying many many time to solve this conflict. But I don't know why occur conflict here. 2 conflicts occur at compliation time. yacc(bison) error goes: State 314 conflicts: 1 shift/reduce State 315 conflicts: 1 shift/reduce state 314 7…
ChangHun Lee
  • 127
  • 1
  • 12
0
votes
1 answer

yacc shift/reduce conflict

I faced conflict problem during yacc compilation. Error message below: 24: shift/reduce conflict (shift 66, reduce 99) on '/' state 24 arithmetic_leaf : absolute_path . (99) absolute_path : absolute_path . '/' relative_path (102) Code…
ChangHun Lee
  • 127
  • 1
  • 12
0
votes
3 answers

byacc shift/reduce

I'm having trouble figuring this one out as well as the shift reduce problem. Adding ';' to the end doesn't solve the problem since I can't change the language, it needs to go just as the following example. Does any prec operand work? The example is…
d0pe
  • 573
  • 4
  • 9
  • 23
-1
votes
2 answers

Shift Reduce Conflict in YACC

I m trying the following yacc code and m receiving shift/reduce errors. I m pretty new to this The Purpose of the code is to prepare the syntax for if - else with logical operators also incorporated %{ #include
-2
votes
1 answer

Shift/Reduce conflict in first state due to epsilon rule

I have shift/reduce conflict in bison. I checked the parser.output file: State 0 0 $accept: . Prog $end STRUCT shift, and go to state 1 $default reduce using rule 6 (Structs) Prog go to state 2 Structs go to state 3 StructDec go…
SuzLy
  • 133
  • 1
  • 10
1 2 3
11
12