Esempio n. 1
0
static action_t cont_macroexpand1() {
  if (iscons(expr)) {
    ref_t symbol = check_symbol(car(expr));
    if (has_function(symbol)) {
      ref_t func = get_function(symbol);
      if (ismacro(func)) {
        C(cont)->fn = cont_apply_apply, C(cont)->val[0] = func;
        expr = cdr(expr);
        return ACTION_APPLY_CONT;
      }
    }
  }
  pop_cont();
  return ACTION_APPLY_CONT;
}
Esempio n. 2
0
//defines a new macro, adds it to the macro list
void new_macro(char *symbol, char *line, char *operand)
{
        extern int source_line_num;
        struct sym *sym;

	if (macro_ctn >= MAX_DEF_MACRO)
                as_exit("Parse Error: Too many macros");

        if(isalpha(*symbol)==0)
                as_exit("Parse Error: Symbol must start with an alpha character");
        
        if(ismacro(symbol)!=-1)
                as_exit("Parsed Error: macro is already defined");

        if(issymbol(symbol,&sym)!=-1)
                as_exit("Parse Error: Symbol is already defined");

        macro[macro_ctn].line_num=source_line_num;
        macro[macro_ctn].ptr=line;
        strcpy(macro[macro_ctn].name,symbol); 
        macro[macro_ctn].operands=operand;
        macro_ctn++;
        
}