title: Operator precedence in programming language
body: <p>In programming Language class, I learned operator precedence and associativity.  The under is simple <em>Context-Free-Grammar</em> </p>
  
  <pre><code>&lt;expr&gt; -&gt; &lt;expr&gt; + &lt;term&gt; | &lt;term&gt;
  &lt;term&gt; -&gt; &lt;term&gt; * &lt;fact&gt; | &lt;fact&gt;
  &lt;fact&gt; -&gt; (&lt;expr&gt;) | a
  </code></pre>
  
  <p>By using Context-Free-Grammar above, we can make the sentence </p>
  
  <pre><code>a+a+(a+a)
  </code></pre>
  
  <p>I think, the order of operation should be done as follow : (a+a) -> a+a then plus altogether. However, on lecture, the professor said both (a+a) -> a+a and 
  a+a -> (a+a) order is right. Student's are in panic. Even in the sentence below,</p>
  
  <pre><code>(a+a)+((a+a))
  </code></pre>
  
  <p>Both order ((a+a)) -> (a+a) then plus and (a+a) -> ((a+a)) is correct.
  He just said, after making parse tree, then converted to the assembly language
  so the order depends on Compiler.</p>
  
  <p>I don't understand his explanation.
  Is anybody can explain why there are two possible order??</p>