             # its corresponding Start token; if it is not,
             # we throw.
             when 'indentEnd'
-              unless mark.token.indent is stack?[stack.length - 1]
+              unless mark.token.indent is stack[stack.length - 1]
                 throw new Error 'Improper parser: indent ended too early.'
               
               # Update stack and indent depth

              
              # If we need to close an autoinserted socket,
              # close it.
              if mark.token.block is autoinsertStack?[autoinsertStack.length - 1]
                autoinsertStack.pop()
                head = head.append stack.pop().end

            when 'socketEnd'
              unless mark.token.socket is stack[stack.length - 1]
                throw new Error 'Improper parser: socket ended too early.'
              
              # Update stack
              stack.pop()

              head = head.append mark.token

          lastIndex = mark.location.column
      

              head = head.append mark.token

            when 'socketStart'
              # A socket is only allowed to be directly inside a block.
              # Currently, our behaviour will be to auto-repair it in
              # some cases, but this
              # might need to be changed in the future.
              #
              # We will auto-repair if it is inside an indent,
              # otherwise we will throw
              unless stack[stack.length - 1]?.type is 'block'
                if stack.length is 0
                  throw new Error 'Improper parser: document root cannot be a socket.'
                else if stack[stack.length - 1].type is 'indent'
                  autoinsertStack.push mark.token.socket

                  autoinsertedBlock = new model.Block()

                  head = head.append autoinsertedBlock.start

                  stack.push autoinsertedBlock

              # Update the stack and append the token.
              stack.push mark.token.socket

