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
-2
votes
1 answer

Bison/yacc Shift/Reduce conflict

I wanted to make a simple Java parser so I've started with this grammar : Programme : Class{ printf("Programme OK!\n");} ; Class : ClassPrototype O_ACCOL VariableDeclaration Main C_ACCOL ClassPrototype : ACCESS CLASS ID…
Romain B
  • 129
  • 2
  • 3
  • 12
-2
votes
1 answer

Can this be parsed by a LALR(1) parser?

I am writing a parser in Bison for a language which has the following constructs, among others: self-dispatch: [identifier arguments] dispatch: [expression . identifier arguments] string slicing: expression[expression,expression] - similar to…
1 2 3
11
12