       throw new Error("addListener can not attach listeners!")
 
 class SinatraRouteParser
-  constructor: (route) ->
+constructor: (route) ->
     @keys = []
     route = route.substring(1)
     segments = []

        throw error
      @previous = matched
      return matched
  find: (path) =>
    for candidate in @routes
      if params = candidate.route.parse(path, @paramVerifier)
        return {params: params, route: candidate.matchedRoute, fn: candidate.fn, urlPattern: candidate.urlPattern, path: path, metadata: candidate.metadata}
  addPostExecutionListener: (fn) =>
    @postExecutionListeners.push(fn)
  addExceptionListener: (fn) =>
    @exceptionListeners.push(fn)

  pushStateSupport: history && history.pushState
  hashchangeSupport: "onhashchange" of window
  hashBaseUrl: false
  previous: false
  disableUrlUpdate: false
  fallbackRoute: false
  init: false
  initDone: false
  paramVerifier: false
  renderCount: 0
  clickCount: 0

  transparentRouting: () =>
    @init = true

  postExecutionListeners: []
  exceptionListeners: []
  debug: false
  previous: false
  paramVerifier: false
  renderCount: 0

  log: =>
    if @debug && window.console && console && console.log
      if JSON.stringify
        console.log("ki-router: " + JSON.stringify(arguments))
      else
        console.log(arguments)

  add: (urlPattern, fn, metadata) =>
    @routes.push({route: new SinatraRouteParser(urlPattern), fn: fn, urlPattern: urlPattern, metadata: metadata})

  exec: (path) =>
    if matched = @find(path)
      @log("Found route for", path, " Calling function with params ", matched.params)
