示例#1
0
void			process_entry(t_sh_token *token, t_envp *envp)
{
  t_int32		ret;
  t_mysh_er		er;
  t_struct_linker	job_list;

  init_linker(&job_list);
  while (token)
    {
      er = 0;
      if (token->up && token->flag & P_SEPARATOR_L)
	{
	  if ((ret = check_if_builtin(token->up->str)) >= 0)
	    {
	      if (test_job(&job_list, token->flag))
		er |= msh_builtin(&job_list, ret, token, envp);
	    }
	  else if ((ret = get_exec_path(envp, token)))
	    er |= ret;
	  else
	    if (token->flag & P_SCOL_F || test_job(&job_list, token->flag))
	      er |= msh_exec(&job_list, token, envp);
	}
      msh_error(er, token->up);
      token = token->next;
    }
  free_jobs((t_job *)job_list.first);
}
示例#2
0
文件: p_main.c 项目: Aessem35/42SH
t_sh_token		*parser(char *str, t_glob_def *def, char end)
{
  t_struct_linker	linker;
  t_sh_token		*token;

  init_linker(&linker);
  if (!(token = tokenize_lex(&linker, str, def, end)))
    return (token);
  params(token);
  return (token);
}
示例#3
0
int main(int argc, char **argv) {
     progname = argv[0];

     buf_init(module, INIT_MODS, 1, struct _module, "modules");
     buf_init(dep, INIT_MODS, 1, int, "dependencies");

     stack_size = STACK_SIZE;

     get_options(argc, argv);
     if (nfiles == 0 && !dump) panic("no input files");
     if (stdlib && libdir == NULL) panic("no libdir specified");
     if (rtlibdir == NULL) rtlibdir = libdir;

     make_prim("INTERP");
     make_prim("DLTRAP");
     
#define bind(x) def_global(find_symbol(#x), ABS, x, X_SYM)

     bind(GC_BASE); bind(GC_REPEAT); bind(GC_BLOCK);
     bind(GC_MAP); bind(GC_FLEX); bind(GC_END);
     bind(E_CAST); bind(E_ASSIGN); bind(E_CASE);
     bind(E_WITH); bind(E_ASSERT); bind(E_RETURN);
     bind(E_BOUND); bind(E_NULL); bind(E_DIV);
     bind(E_FDIV); bind(E_STACK); bind(E_GLOB);

     /* First pass -- check for dependencies */
     scan_files();

     /* Compute needed modules */
     buf_grow(module);
     module[nmodules].m_dep = ndeps;
     trace_imports();

     if (status != 0) return status;

     /* Second pass -- link the modules that are needed */
     if (!dump) {
	  init_linker(outname, interp);
	  load_needed();
	  gen_main();
	  if (rtlibdir != NULL)
	       save_string("LIBDIR", rtlibdir);
	  end_linking();
     }

     if (dump || custom) {
	  printf("/* Primitive table -- generated by oblink */\n\n");
	  printf("#include \"obx.h\"\n\n");
	  dump_prims(stdout);
     }

     return status;
}
示例#4
0
文件: p_main.c 项目: Aessem35/42SH
void			params(t_sh_token *token)
{
  t_struct_linker	linker;

  while (token)
    {
      init_linker(&linker);
      tokenize_param(&linker, token->str, " \t");
      token->up_size = linker.size;
      token->up = (t_sh_token *)linker.first;
      token = token->next;
    }
}