title: Ambiguous grammar and possible fixes
body: <p>So I have this grammar for a language, the grammar certainly contains some ambiguity however I am finding it a bit unusually difficult to fix this one. Below is the BNF grammar of the language and below that part of my happy parser file. </p>
  
  <p>BNF of the proposed language:</p>
  
  <pre><code>&lt;program&gt; ::=                                   Skel program
        "program" &lt;id&gt; ":" &lt;pars&gt; "."
  
  --&gt; &lt;pars&gt; ::=
        &lt;par&gt; [";" &lt;pars&gt;]                        parallel statements
  
  &lt;par&gt; ::=
      "func" &lt;id&gt; &lt;structs&gt;                       structured expression
  --&gt; |   &lt;pars&gt; "||" &lt;pars&gt;                          parallel pipeline
  |   "farm" &lt;int&gt; &lt;pars&gt;                         task farm
  
  --&gt; &lt;structs&gt; ::=
      &lt;struct&gt; [";" &lt;structs&gt;]                    statements
  
  &lt;struct&gt; ::=
        &lt;exprs&gt;                                   expression
  --&gt; |     &lt;structs&gt; "•" &lt;structs&gt;                   composition
  |     "iter" &lt;int&gt; &lt;structs&gt;                    iteration
  
  --&gt; &lt;exprs&gt; ::=
        &lt;expr&gt; ["," &lt;exprs&gt;]                      expressions
  
  &lt;expr&gt; ::=
      &lt;int&gt;                                       integer value
      |  &lt;string&gt;                                 string value
      |  &lt;bool&gt;                                   boolean value
      |  &lt;id&gt; [ "=" &lt;exprs&gt; ]                     identifier/assignment
      |  "raise" &lt;id&gt; "=" &lt;exprs&gt;                 raise exception
      |  &lt;exprs&gt; "catch" &lt;id&gt; &lt;id&gt; ":" &lt;exprs&gt;    catch exception
      |  &lt;exprs&gt; &lt;op&gt; &lt;exprs&gt;                     binary operator
      |  "(" &lt;exprs&gt; ")"                          grouping
  
  &lt;op&gt; ::=                        operators
      "+" | "*" | "-" | "div"| "&lt;"| "&lt;=" | "==" | "!="
  </code></pre>
  
  <p><strong>Parser.y</strong></p>
  
  <pre><code>TProgram: program ID ':' TPars '.'    { Program $2 $4 }
  
  TPars   : TPar ';'                    {   [$1]  }
          | TPars TPar                  { $2 : $1 }
  
  TPar    : func ID TStructs            { Function $2 $3   }
        --| "||" TPars                  { Parall $2        }
          | farm DIGIT TPars            { Farm $2 $3       }
  
  TStructs: TStruct ';'                 {  [$1]  }
          | TStructs TStruct            { $2 : $1 }
  
  TStruct : TExprs                      { ExprList $1   }
        --| '•' TStructs                { CompOp $2     }
          | iter DIGIT TStructs         { Iter $2 $3    }
  
  TExprs  : TExpr                       {   [$1]    }
          | TExprs ',' TExpr            {  $3 : $1  }
  
  BinExpr : Term                        {  $1  }
          | BinExpr Op BinExpr          { BinOp $2 $1 $3  }
  
  Op      : '/'                         { Divide }
          | '*'                         { Times  }
          | '-'                         { Minus  }
          | '+'                         { Plus   }
  
  Term    : ID                          { Var $1 }
          | DIGIT                       { Digit $1 }
          | FLOAT                       { Float $1 }
  
  TExpr   : '(' TExprs ')'              { ParenExpr $2 }
          | true                        { Bool $1  }
          | false                       { Bool $1  }
          | ID '=' TExprs               { Assign $1 $3  }
          | raise ID '=' TExprs         { Raise $2 $4   }
          | BinExpr                     {  $1  }
  </code></pre>
  
  <p><strong>Edit</strong> : I've added arrows to the BNF format showing what I believe is causing the ambiguity in the grammar.</p>