let rec collect_scripts input =
  while key input "Goal" do
    let g = ident input in
    eat input "." ;
    let xs =
      if key input "Hint" then
        let xs = idents input in
        eat input "." ; xs
      else [] in
    let p =
      match token input with
        | Proof p -> skip input ; p
        | _ -> error input "Missing proof"
    in
    register_script g xs p
  done ;
  if token input <> Eof
  then error input "Unexpected script declaration"