title: Coco/r: Factor deletable
body: <p>I am trying to implement a language in Coco/r for arithmetic operations in C# which takes operator precedence into consideration. My ATG code looks like this:</p>
  
  <pre><code>/* Coco/R lexer and parser specification for arithmetic expressions. */
  /* 2006-09-14 */
  
  /* Build with:
   *   Coco.exe -namespace Expressions Ex2.ATG
   */
  
  using System.Collections.Generic;
  
  COMPILER Expressions
    public int res;
  
  /*--------------------------------------------------------------------------*/
  CHARACTERS
    letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".
    digit = "0123456789".
    cr  = '\r'.
    lf  = '\n'.
    tab = '\t'.
  
  TOKENS
    ident  = letter {letter | digit}.
    number = digit {digit}.
  IGNORE cr + lf + tab
  
  PRODUCTIONS
  /*------------------------------------------------------------------------*/
  Expr&lt;out int n&gt;   (. int n1, n2; .)
  = Term&lt;out n1&gt;  (. n = n1; .)
  {
    '+' Term&lt;out n2&gt;  (. n = n+n2; .)  
    | 
    '-' Term&lt;out n2&gt;  (. n = n-n2; .)    
    |
    Factor&lt;out int n&gt;
  }
  .
  Factor&lt;out int n&gt;
  =
  {
    "==" Term&lt;out n2&gt; (. if(n1 == n2){ n = 1; } else { n = 2; } .)
    | 
    '&lt;' Term&lt;out n2&gt;  (. if(n1 &lt; n2) { n = 1; } else { n = 0; } .)
    | 
    '&gt;' Term&lt;out n2&gt;  (. if(n1 &gt; n2) { n = 1; } else { n = 0; } .)
    | 
    "!=" Term&lt;out n2&gt; (. if(n1 != n2){ n = 1; } else { n = 0; } .) 
    | 
    "&lt;=" Term&lt;out n2&gt; (. if(n1 &lt;= n2){ n = 1; } else { n = 0; } .)
    | 
    "&gt;=" Term&lt;out n2&gt; (. if(n1 &gt;= n2){ n = 1; } else { n = 0; } .)
    |
    "|" Term&lt;out n2&gt;  (. if(n1 != 0 | n2 != 0) { n = 1; } else { n = 0; } .)
    |
    "&amp;" Term&lt;out n2&gt;  (. if(n1 != 0 &amp; n2 != 0){ n = 1; } else { n = 0; } .)
  }
  .
  Term&lt;out int n&gt; 
  = number          (. n = Convert.ToInt32(t.val); .)
  {
    '*' number  (. n = n*Convert.ToInt32(t.val); .) 
  }
  .
  
  Expressions                        (. int n; .)
  = Expr&lt;out n&gt;                (. res = n; .)
  
  .
  
  
  END Expressions.
  </code></pre>
  
  <p>The operators other than '+' and '-' should have lower precedence. Moreover, the '&amp;' operator should have lower precedence than '|'.</p>
  
  <p>The problem is that when I try to test the code I get the following errors:</p>
  
  <pre><code>Factor deletable
    LL1 warning in Expr: contents of [...] or {...} must not be deletable
    LL1 warning in Expr: "+" is start of several alternatives
    LL1 warning in Expr: "-" is start of several alternatives
    LL1 warning in Factor: "==" is start &amp; successor of deletable structure
    LL1 warning in Factor: "&lt;" is start &amp; successor of deletable structure
    LL1 warning in Factor: "&gt;" is start &amp; successor of deletable structure
    LL1 warning in Factor: "!=" is start &amp; successor of deletable structure
    LL1 warning in Factor: "&lt;=" is start &amp; successor of deletable structure
    LL1 warning in Factor: "&gt;=" is start &amp; successor of deletable structure
    LL1 warning in Factor: "|" is start &amp; successor of deletable structure
    LL1 warning in Factor: "&amp;" is start &amp; successor of deletable structure
  </code></pre>
  
  <p>I am really new in Coco/r and EBNF. I had a look into Coco\r's manual, but I don't really see what is the problem; What am i missing?</p>
  
  <p>Thank you in advance!</p>