Exemple #1
0
int		fill_tree(t_shell *shell, char *command_line)
{
  t_tree	*up;
  char		**commands;
  int		i;

  if ((commands = my_str_to_wordtab(command_line, " \t")) == NULL)
    return (nothing_more(shell));
  i = -1;
  while (commands != NULL && commands[++i] != NULL)
    {
      if ((is_token(shell->tokens, commands[i]) >= 0) &&
	  ((shell->tree->right = malloc(sizeof(t_tree))) != NULL))
	{
	  shell->tree->token = is_token(shell->tokens, commands[i]);
	  if ((shell->tree->left = get_left(commands, i)) == NULL)
	    return (-1);
	  up = shell->tree;
	  shell->tree = shell->tree->right;
	  shell->tree->up = up;
	  return (fill_tree(shell, new_command(commands, i)));
	}
    }
  return (last_command(shell, commands, i));
}
 //------------------------------------------------------------------------
 double path_tokenizer::next(char cmd)
 {
     if(!next()) throw exception("parse_path: Unexpected end of path");
     if(last_command() != cmd)
     {
         char buf[100];
         sprintf(buf, "parse_path: Command %c: bad or missing parameters", cmd);
         throw exception(buf);
     }
     return last_number();
 }