anchor.diff:      project ""<filename>""
         - associates the current session with the specified project"
   
  +  let outputText = @"
  +    Output format
  +    =============
  +
  +    Messages are in one of the following three forms:
  +
  +    1. INFO: text
  +
  +       A single line with a free text field. Returns information.
  +
  +    2. ERROR: text
  +
  +       A single line with a free text field. An error has occurred.
  +  
  +    3. DATA: word number
  +       text
  +
  +       Some data, where 'word' (in [a-z]+) indicates the type of data
  +       and 'number' (in [0-9]+) indicates the number of bytes of free
  +       text that will follow."
  +
     // Command that can be entered on the command-line
     type Command =
       | Completion of string * Position * int option
  
positive.code:                                     file,
                                      text)
            agent.TriggerParseRequest(opts, full)
            Console.WriteLine("DONE: Background parsing started")
            main { state with Files = Map.add file lines state.Files }
          else
            Console.WriteLine(sprintf "ERROR: File '%s' does not exist" file)
            main state
  
      | Project file ->
          // Load project file and store in state
          if File.Exists file then
            match ProjectParser.load file with
            | Some p -> Console.WriteLine("DONE: Project loaded")
                        main { state with Project = Some p }
            | None   -> Console.WriteLine(sprintf "ERROR: Project file '%s' is invalid" file)
                        main state
          else
            Console.WriteLine(sprintf "ERROR: File '%s' does not exist" file)
            main state
  
      // TODO: Refactor error checking of next four cases
      | Declarations file ->
          let file = Path.GetFullPath file
          if not (Map.containsKey file state.Files)
          then
            Console.WriteLine(sprintf "ERROR: File '%s' not parsed" file)
            Console.WriteLine("<<EOF>>")
          else
            let lines = state.Files.[file]
            let text = String.concat "\n" lines
            let opts = RequestOptions(agent.GetCheckerOptions(file, text, state.Project),
  
negative.code:           let decls = agent.GetDeclarations(opts)
            for tld in decls do
              let (s1, e1), (s2, e2) = tld.Declaration.Range
              sprintfn "[%d:%d-%d:%d] %s" e1 s1 e2 s2 tld.Declaration.Name
              for d in tld.Nested do
                let (s1, e1), (s2, e2) = d.Range
                sprintfn "  - [%d:%d-%d:%d] %s" e1 s1 e2 s2 d.Name
          main state
  
      | ToolTip(file, ((line, col) as pos), timeout) ->
          let file = Path.GetFullPath file
          if parsed file and posok file line col then
            let text = String.concat "\n" state.Files.[file]
            let opts = RequestOptions(agent.GetCheckerOptions(file, text, state.Project),
                                      file,
                                      text)
            agent.GetToolTip(opts, pos, lines.[line], timeout)
          main state
  
      | Completion(file, ((line, column) as pos), timeout) ->
          let file = Path.GetFullPath file
          if parsed file and posok file line col then
            let text = String.concat "\n" state.Files.[file]
            let opts = RequestOptions(agent.GetCheckerOptions(file, text, state.Project),
                                      file,
                                      text)
            agent.DoCompletion(opts, pos, lines.[line], timeout)
          main state
  
      | FindDeclaration(file, ((line, column) as pos), timeout) ->
          if parsed file and posok file line col then
            let text = String.concat "\n" state.Files.[file]
            let opts = RequestOptions(agent.GetCheckerOptions(file, text, state.Project),
                                      file,
                                      text)
            agent.FindDeclaration(opts, pos, lines.[line], timeout)
          main state
  
      | Help ->
          Console.WriteLine(helpText)
          main state
  