           mlabel += char
       return mlabel
 
+    # Draw the node as a string.
+    #
+    # @return [String] This node drawn as a string.
     renderString: ->
       return @label
 
+    # Draw the node as MathML.
+    #
+    # @return [String] This node drawn as MathML.
     renderMathML: ->
       labelArray = @label.split("-")
       label = labelArray[0]

    node.terms = terms
    return node

  class Add extends DrawingNode
    constructor: (@terms...) ->

    bindingStrength: ->
      4

    renderLaTeX: ->
      return @terms.map((x) -> x.renderLaTeX()).join(" + ")

    renderString: ->
      return @terms.map((x) -> x.renderString()).join(" + ")

    renderMathML: ->
      return @terms.map((x) -> x.renderMathML())
                   .join("<mo>+</mo>")

  class Mul extends DrawingNode
    constructor: (@terms...) ->

    bindingStrength: ->
      6

    renderLaTeX: ->
      return @terms.map((x) -> x.renderLaTeX()).join(" \\cdot ")

    renderString: ->
      return @terms.map((x) -> x.renderString()).join("*")

    renderMathML: ->
      return @terms.map((x) -> x.renderMathML()).join("<mo>&middot;</mo>")

  class Pow extends DrawingNode
    constructor: (@left, @right) ->

    renderLaTeX: ->
      "#{@left.renderLaTeX()}^{#{@right.renderLaTeX()}}"

    renderString: ->
      "#{@left.renderString()}**#{@bracketIfNeeded(@right).renderString()}"

    renderMathML: ->
      "<msup>#{@left.renderMathML()}#{@right.renderMathML()}</msup>"


  class Bracket extends DrawingNode
    constructor: (@contents) ->

    bindingStrength: ->
      9

    renderLaTeX: ->
      return "\\left(#{@contents.renderLaTeX()}\\right)"

    renderString: ->
      return "(#{@contents.renderString()})"

    renderMathML: ->
      return "<mfenced><mrow>#{@contents.renderMathML()}" +
                                                                "</mrow></mfenced>"

  class Number extends DrawingNode
    constructor: (@value) ->

    bindingStrength: ->
      10

    renderLaTeX: ->
      return @value+""

    renderString: ->
      return @value+""

    renderMathML: ->
      return "<mn class=\"constant\">#{@value}</mn>"

  class Variable extends DrawingNode
    constructor: (@label, @classname="variable") ->

    bindingStrength: ->
      10

    renderLaTeX: ->
      # Check for Greek characters.
      mlabel = ""

                  #{@contents.renderMathML(x...)}
                </msqrt>"

  # Drawing node representing an uncertainty.
  class Uncertainty extends DrawingNode
    
    # Make a new uncertainty drawing node.
    #
    # @param label [String] The label of the variable this uncertainty represents.
    # @param class [String] Optional. The name that should be set as the class for this node if drawn as MathML or similar.
    constructor: (@label, @class="default") ->

    # How strongly this node is bound.
    #
    # @return [Number] Binding strength.
    bindingStrength: ->
      9

    # Draw the node as a LaTeX string.
    #
    # @return [String] This node drawn as LaTeX.
    renderLaTeX: ->
      return "\\sigma_{#{@label}}"

    # Draw the node as a string.
    #
    # @return [String] This node drawn as a string.
    renderString: ->
      return "σ(#{@label})"

    # Draw the node as MathML.
    #
    # @return [String] This node drawn as MathML.
    renderMathML: (x...)->
      dummy = new Variable(@label)
      return "<msub><mo>&sigma;</mo>#{dummy.renderMathML(x...)}</msub>"
