Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A shift/reduce is a CONFLICT not an ERROR -- it tells you the grammar is not LALR(1), so the parser produced by bison may only recognize a subset of your language. That may be a problem, or it might not be.</p> <p>In your case, the problem comes from the fact that <code>C</code> has an optional <code>COMMA</code> before the <code>CLOSINGBRACES</code>, but the grammar needs to complete(reduce) the <code>B</code> before it can go ahead to parse the <code>C</code>. So when you have an input like <code>{ INT , INT , }</code>, when it gets to the second <code>COMMA</code> it doesn't know whether it should reduce the <code>B</code> (completing the list), or shift the <code>COMMA</code> to get another <code>constant</code> to add to the list. In this case it should reduce (because the <code>COMMA</code> shoud be part of the <code>C</code> rule), but it doesn't know that without two token lookahead to see the <code>}</code> after the <code>,</code>.</p> <p>In this case, the default resolution of the shift/reduce conflict as shift means that the parser will always expect another value after the comma, so will end up parsing the language without the optional comma (as if the rule <code>C: COMMA CLOSINGBRACES</code> did not exist)</p> <p>One easy way to fix this is to make your <code>B</code> rule left-recursive instead of right-recursive:</p> <pre><code>B: A | B COMMA A ; </code></pre> <p>This way a <code>B</code> is a valid prefix of a <code>B</code>, so the parser can always reduce a <code>B</code> and then add additional <code>A</code>s on to the end of it later (after shifting the COMMA and seeing what the next token is).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload