 {car, cdr, cons, nil, nilp, pairp, vectorToList, list} = require 'cons-lists/lists'
-{length} = require 'cons-lists/reduce'
 {inspect} = require "util"
+
 
 NEWLINES   = ["\n", "\r", "\x0B", "\x0C"]
 WHITESPACE = [" ", "\t"].concat(NEWLINES)
 
 EOF = new (class Eof)()
 EOO = new (class Eoo)()
-
-stringp = (o) -> o?.__type == 'string'
-
-errorp = (o) -> (pairp o) and (car o) == 'error'
-
-streq = (s, t) -> String(s) == String(t)
 
 class Source
   constructor: (@inStream) ->


# Given a stream, reads from the stream until a single complete lisp
# object has been found and returns the object
# IO -> Form
read = (inStream, eofErrorP = false, eofError = EOF,
        recursiveP = false, inReadMacros = null, keepComments = false) ->
  inStream = if inStream instanceof Source then inStream else new Source inStream
  inReadMacros = if InReadMacros? then inReadMacros else readMacros
  inReadMacroKeys = (i for i of inReadMacros)

    inStream.next()).join("")
  if not inStream.done()
    inStream.next()
  makeObj 'comment', r, line, column

# IO -> (Node => Literal => String) | Error
readString = (inStream) ->
  [line, column] = inStream.position()
  inStream.next()
  string = until inStream.peek() == '"' or inStream.done()
    if inStream.peek() == '\\'
      inStream.next()
    inStream.next()
  if inStream.done()
    return handleError("end of file seen before end of string.")(line, column)
  inStream.next()
  makeObj 'string', (string.join ''), line, column

# (String) -> (Node => Literal => Number) | Nothing
readMaybeNumber = (symbol) ->
  if symbol[0] == '+'
    return readMaybeNumber symbol.substr(1)
  if symbol[0] == '-'
    ret = readMaybeNumber symbol.substr(1)
    return if ret? then -1 * ret else undefined
  if symbol.search(/^0x[0-9a-fA-F]+$/) > -1
