generate necessary parenthesis in composite expressions

This updates the language model to write parenthesis for expressions
that need them.  E.g., ( 1 + 2 ) * 3.

There are two parts to the solution.  Firstly, every expression is
assigned a precedence.  The precedence levels are defined from:

    http://www.tech-uofm.info/spring_2011/TECH1211/Precedence_Table.pdf

This table ranks all expressions and also specifies the directional
associativity.  At this point only the ranking is used.

The second part of the solution is to change the #write functions for
all places where expressions are written within expressions.  For
example, in a BinaryOperation, both the left-hand side and right-hand
side are written within the containing binary operation.

At each of these points, the target expression's precedence is compared
with the precedence of the containing expression.  The inner expression
is wrapped with parenthesis where needed.

Finally, some convenience functions are provided to implement this
functionality.

I've updated the test suite with some targetted tests.  Existing test
cases are unaffected.

Change-Id: Icdab76b78f1bc91a2f186d21cd321b0dafea71e6
Signed-off-by: Andrew Eidsness <andrewe@jfront.com>
23 files changed
tree: 7dd7754c4b2ba0831f77f94bde941c5c4cb554b7
  1. codegen/
  2. rts/
  3. .gitignore
  4. epl-v10.html
  5. notice.html
  6. pom.xml