       throw ("Syntax Error. Expected " + t + " found '") + lookahead.value + "' near '" + input.substr(lookahead.from) + "'"
     return
 
-  statements = ->
-    result = [statement()]
-    while lookahead and lookahead.type is ";"
-      match ";"
-      result.push statement()
-    if result.length is 1
-      result[0]
+  # PL/0
+  program = ->
+    result = block()
+    if lookahead and lookahead.type is "."
+      match "."
     else
-      result
+      throw "Error. Expecting '.' to end program"
+    result
+
+  block = ->
+    result = []
+    if lookahead and lookahead.type is "CONST"
+      match "CONST"
+
+      if lookahead and lookahead.type is "ID"
+        varname = lookahead.value
+        match "ID"
+
+        if lookahead and lookahead.type is "ASSIGN"
+          match "ASSIGN"
+
+          if lookahead and lookahead.type is "NUMBER"
+            numval = lookahead.value
+            match "NUMBER"
+            result.push (
+              type: "CONSTVAR"
+              value: numval
+            )
+            match ";"
+          else
+            throw "Error. Expecting a number"
+        else
+          throw "Error. Constants must be initialized"
+      else
+        throw "Error. Expecting an identifier"
+
+
+    if lookahead and lookahead.type is "VAR"
+      match "VAR"
+
+      if lookahead and lookahead.type is "ID"
+        varname = lookahead.value
+        match "ID"
+        match ";"
+        result.push (
+          type: "VAR"
+          name: varname
+        )
+      else
+        throw "Error. Expecting ID"
+
+    if lookahead and lookahead.type is "PROCEDURE"
+      match "PROCEDURE"
+
+      if lookahead and lookahead.type is "ID"
+        nvalue = lookahead.value
+        match "ID"
+        match ";"
+        result.push (
+          type: "PROCEDURE"
+          name: nvalue
+          content: block()
+        )
+        match ";"
+      else
+        throw "Error. Expecting ID"
+
+    statement()
 
   statement = ->
-    result = null
-    if lookahead and lookahead.type is "ID"
-      left =
-        type: "ID"
-        value: lookahead.value
-
-      match "ID"
-      match "="
-      right = expression()
-      result =
-        type: "="
-        left: left
-        right: right
-    else if lookahead and lookahead.type is "P"
-      match "P"
-      right = expression()
-      result =
-        type: "P"
-        value: right
-    else if lookahead and lookahead.type is "IF"
-      match "IF"
-      left = condition()
-      match "THEN"
-      right = statement
-      result =
-        type: "IF"
-        left: left
-        right: right
-    else
-      throw "Syntax Error. Expected identifier but found " + ((if lookahead then lookahead.value else "end of input")) + (" near '" + (input.substr(lookahead.from)) + "'")
-    result
-
-  condition = ->
-    left = expression()
-    type = lookahead.value
-    match "COMPARISON"
-    right = expression()
-    result =
-      left: left
-      right: right
-      type: type
-    result
-
-  expression = ->
-    result = term()
-    if lookahead and lookahead.type is "+"
-      match "+"
-      right = expression()
-      result =
-        type: "+"
-        left: result
-        right: right
-    else if lookahead and lookahead.type is "-"
-      match "-"
-      right = expression()
-      result =
-        type: "-"
-        left: result
-        right: right
-    result
-
-  term = ->
-    result = factor()
-    if lookahead and lookahead.type is "*"
-      match "*"
-      right = term()
-      result =
-        type: "*"
-        left: result
-        right: right
-    else if lookahead and lookahead.type is "/"
-      match "/"
-      right = term()
-      result =
-        type: "/"
-        left: result
-        right: right
-    result
-
-  factor = ->
-    result = null
-    if lookahead.type is "NUM"
-      result =
-        type: "NUM"
-        value: lookahead.value
-
-      match "NUM"
-    else if lookahead.type is "ID"
-      result =
-        type: "ID"
-        value: lookahead.value
-
-      match "ID"
-    else if lookahead.type is "("
-      match "("
-      result = expression()
-      match ")"
-    else
-      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)
-  throw "Syntax Error parsing statements. " + "Expected 'end of input' and found '" + input.substr(lookahead.from) + "'"  if lookahead?
-  tree+    result = []
+
+
+  # Anterior
+  #statements = ->
+  #  result = [statement()]
+  #  while lookahead and lookahead.type is ";"
+  #    match ";"
+  #    result.push statement()
+  #  if result.length is 1
+  #    result[0]
+  #  else
+  #    result
+
+  #statement = ->
+  #  result = null
+  #  if lookahead and lookahead.type is "ID"
+  #    left =
+  #      type: "ID"
+  #      value: lookahead.value
+
+  #    match "ID"
+  #    match "="
+  #    right = expression()
+  #    result =
+  #      type: "="
+  #      left: left
+  #      right: right
+  #  else if lookahead and lookahead.type is "P"
+  #    match "P"
+  #    right = expression()
+  #    result =
+  #      type: "P"
+  #      value: right
+  #  else if lookahead and lookahead.type is "IF"
+  #    match "IF"
+  #    left = condition()
+  #    match "THEN"
+  #    right = statement
+  #    result =
+  #      type: "IF"
+  #      left: left
+  #      right: right
+  #  else
+  #    throw "Syntax Error. Expected identifier but found " + ((if lookahead then lookahead.value else "end of input")) + (" near '" + (input.substr(lookahead.from)) + "'")
+  #  result
+
+  #condition = ->
+  #  left = expression()
+  #  type = lookahead.value
+  #  match "COMPARISON"
+  #  right = expression()
+  #  result =
+  #    left: left
+  #    right: right
+  #    type: type
+  #  result
+
+  #expression = ->
+  #  result = term()
+  #  if lookahead and lookahead.type is "+"
+  #    match "+"
+  #    right = expression()
+  #    result =
+  #      type: "+"
+  #      left: result
+  #      right: right
+  #  else if lookahead and lookahead.type is "-"
+  #    match "-"
+  #    right = expression()
+  #    result =
+  #      type: "-"
+  #      left: result
+  #      right: right
+  #  result
+
+  #term = ->
+  #  result = factor()
+  #  if lookahead and lookahead.type is "*"
+  #    match "*"
+  #    right = term()
+  #    result =
+  #      type: "*"
+  #      left: result
+  #      right: right
+  #  else if lookahead and lookahead.type is "/"
+  #    match "/"
+  #    right = term()
+  #    result =
+  #      type: "/"
+  #      left: result
+  #      right: right
+  #  result
+
+  #factor = ->
+  #  result = null
+  #  if lookahead.type is "NUM"
+  #    result =
+  #      type: "NUM"
+  #      value: lookahead.value
+
+  #    match "NUM"
+  #  else if lookahead.type is "ID"
+  #    result =
+  #      type: "ID"
+  #      value: lookahead.value
+
+  #    match "ID"
+  #  else if lookahead.type is "("
+  #    match "("
+  #    result = expression()
+  #    match ")"
+  #  else
+  #    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)
+  #throw "Syntax Error parsing statements. " + "Expected 'end of input' and found '" + input.substr(lookahead.from) + "'"  if lookahead?
+  #tree

    from = i

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


  tokens =
    WHITES: /\s+/g
    ONELINECOMMENT: /\/\/.*/g
    MULTIPLELINECOMMENT: /\/[*](.|\n)*?[*]\//g
    ID: /[a-zA-Z_]\w*/g
    NUM: /\b\d+(\.\d*)?([eE][+-]?\d+)?\b/g
    STRING: /('(\\.|[^'])*'|"(\\.|[^"])*")/g
    ASSIGNOPERATOR: /:=/g
    COMPARISONOPERATOR: /[<>]=|[<>=#]/g
    ADDSUBOPERATOR: /[+-]/g
    MULTDIVOPERATOR: /[*\/]/g
    ONECHAROPERATOR: /([()&|;:,<>{}[\]])/g

  RESERVED_WORD =
    const: "CONST"
    "var": "VAR"
    procedure: "PROCEDURE"
    call: "CALL"
    begin: "BEGIN"
    end: "END"
    "if": "IF"
    then: "THEN"
    "while": "WHILE"
    "do": "DO"
    odd: "ODD"

  make = (type, value) ->
    type: type
