     ONECHAROPERATORS
   ]
   RESERVED_WORD = p: "P"
-  
-  # Make a token object.
   make = (type, value) ->
     type: type
     value: value

      match "("
      result = expression()
      match ")"
    else # Throw exception
      throw "Syntax Error. Expected number or identifier or '(' but found " + 
        (if lookahead then lookahead.value else "end of input") + 
        " near '" + input.substr(lookahead.from) + "'"
    result

  tree = statements(input)
  if lookahead?
    throw "Syntax Error parsing statements. " + 
      "Expected 'end of input' and found '" + 
      input.substr(lookahead.from) + "'"  
  tree

    to: i

  getTok = ->
    str = undefined
    str = m[0]
    i += str.length
    str

  return  unless this
  while i < @length
    tokens.forEach (t) ->
      t.lastIndex = i
      return

    from = i
    if m = WHITES.bexec(this) or (m = ONELINECOMMENT.bexec(this)) or (m = MULTIPLELINECOMMENT.bexec(this))
      getTok()
    else if m = ID.bexec(this)
      rw = RESERVED_WORD[m[0]]
      if rw
        result.push make(rw, getTok())
      else
        result.push make("ID", getTok())
    else if m = NUM.bexec(this)
      n = +getTok()
      if isFinite(n)
        result.push make("NUM", n)
      else
        make("NUM", m[0]).error "Bad number"
    else if m = STRING.bexec(this)
      result.push make("STRING", getTok().replace(/^["']|["']$/g, ""))
    else if m = ONECHAROPERATORS.bexec(this)
      result.push make(m[0], getTok())
    else
      throw "Syntax error near '" + (@substr(i)) + "'"
  result

parse = (input) ->
  expression = undefined
  factor = undefined
  lookahead = undefined
  match = undefined
  statement = undefined
  statements = undefined
  term = undefined
  tokens = undefined
  tree = undefined
  tokens = input.tokens()
  lookahead = tokens.shift()
  match = (t) ->
    if lookahead.type is t
      lookahead = tokens.shift()
      lookahead = null  if typeof lookahead is "undefined"
    else
      throw ("Syntax Error. Expected " + t + " found '") + lookahead.value + "' near '" + input.substr(lookahead.from) + "'"
    return

  statements = ->
    result = undefined
    result = [statement()]
    while lookahead and lookahead.type is ";"
      match ";"
      result.push statement()
    if result.length is 1
      result[0]
    else
      result

  statement = ->
    left = undefined
    result = undefined
    right = undefined
    result = null
    if lookahead and lookahead.type is "ID"
      left =
