Exemplo n.º 1
0
void cpp_from_isl::process_node(isl_ast_node *node)
{
    auto type = isl_ast_node_get_type(node);
    switch(type)
    {
    case isl_ast_node_for:
        process_for(node); break;
    case isl_ast_node_if:
        process_if(node); break;
    case isl_ast_node_block:
        process_block(node); break;
    case isl_ast_node_user:
        process_user(node); break;
    case isl_ast_node_mark:
    {
        // TODO: label the stmt?
        auto marked_node = isl_ast_node_mark_get_node(node);
        process_node(marked_node);
        isl_ast_node_free(marked_node);
        break;
    }
    default:
        throw error("Unexpected AST node type.");
    }
}
Exemplo n.º 2
0
	void parser::process_statement(executable_unit & output)
	{
		if
		(
			!
			(
				process_if(output) ||
				process_while(output) ||
				process_for(output) ||
				process_return(output)
			)
		)
		{
			output.type = executable_unit_type::statement;
			parse_tree_node * & node = output.statement_pointer;
			node = new parse_tree_node;
			process_offset_atomic_statement(*node);

			/*
			line_offset++;
			std::cout << "process_statement" << std::endl;
			*/
		}
	}
Exemplo n.º 3
0
// generates code to implement node's action
static void implement_node(ast_node node){
  if (node != NULL){
    if (node->node_type == ROOT){
      process_root(node); 
    }
    // generate code for assignment operator
    else if (node->node_type == OP_ASSIGN){
      process_assign(node); 
    }
    // generate code for negate operator
    else if (node->node_type == OP_NEG) {
      process_negate(node); 
    }
    // generate code for  +, -, *, /, %, =, !=, <, <=, >, >=
    else if (node->node_type > 0 && node->node_type <= 16 && node->node_type != 14 && node->node_type != 15){
      process_math(node); 
    }
    else if (node->node_type == OP_INC){
      process_inc(node, "1"); 
    }
    else if (node->node_type == OP_DEC){
      process_inc(node, "-1"); 
    }
    else if (node->node_type == IF_STMT){
      process_if(node); 
    }
    else if (node->node_type == IF_ELSE_STMT){
      process_ifelse(node); 
    }
    else if (node->node_type == CMPD){
      process_cmpd(node); 
    }
    else if (node->node_type == WHILE_STMT){
      process_while(node); 
    }
    else if (node->node_type == DO_WHILE_STMT){
      process_dowhile(node); 
    }
    else if (node->node_type == OP_AND){
      process_and(node); 
    }
    else if (node->node_type == OP_OR){
      process_or(node); 
    }
    else if (node->node_type == FOR_STRT || node->node_type == FOR_COND || node->node_type == FOR_UPDT){
      process_for_header(node); 
    }
    else if (node->node_type == FOR_STMT){
      process_for(node); 
    }
    else if (node->node_type == READ_STMT){
      process_read(node); 
    }
    else if (node->node_type == PRINT_STMT){
      process_print(node); 
    }
    else if (node->node_type == RETURN_STMT){
      process_return(node); 
    }
    else if (node->node_type == FUNCDEC){
      process_function(node); 
    }
    else if (node->node_type == PARAMS){
      process_params(node); 
    }
    else if (node->node_type == INT_TYPE || node->node_type == DOUBLE_TYPE){
      process_vardec(node); 
    }
    else if (node->node_type == CALL){
      process_call(node); 
    } 
    else if (node->node_type == IDENT){
      process_id(node); 
    } 
    else if (node->node_type == ARRAY){
      process_array(node); 
    }
  }
}
Exemplo n.º 4
0
i4
Is_it_If_statement(FILE *testFile,i4 *counter,bool Ignore_it)
{
    char                  *cp1 = NULL ;
    char                  *cp2 = NULL ;
    i4                     cmd ;
    bool                   yes_its_if = FALSE ;
    bool                   yes_its_tc = FALSE ;

    cmd = 0;
    if ((!shellMode)&&(SEP_CMstlen(lineTokens[0],0) > 1)&&
	(CMcmpcase(lineTokens[0],ERx(".")) == 0))
    {
	cp1 = buffer_1 ;		/* Fix the ".if" statement. */
	cp2 = buffer_2 ;

	STcopy(buffer_1, holdBuf);
	CMcpyinc(cp1,cp2);
	CMcpychar(ERx(" "),cp2);
	CMnext(cp2);
	STcopy(cp1, cp2);
	STcopy(buffer_2, buffer_1);
	break_line(buffer_2, counter, lineTokens);
    }

    cmd = classify_cmmd(sepcmmds, lineTokens[1]);
    if (cmd == IF_CMMD || cmd == ELSE_CMMD || cmd == ENDIF_CMMD)
    {
	yes_its_if = TRUE;
    }
    else if (cmd == TEST_CASE_CMMD || cmd == TEST_CASE_END_CMMD)
    {
	yes_its_tc = TRUE;
    }

    if (yes_its_if || yes_its_tc)
    {
	append_line(holdBuf, 0);

	if (Ignore_it)
	    ignore_silent == TRUE;

	if (yes_its_if)
	{
	    process_if(testFile, lineTokens, cmd);
	}
	else if (yes_its_tc)
	{
	    if (cmd == TEST_CASE_CMMD)
	    {
		testcase_start(&lineTokens[1]);
	    }
	    else if (cmd == TEST_CASE_END_CMMD)
	    {
		testcase_end(FALSE);
	    }
	}

	if (Ignore_it)
	    ignore_silent == FALSE;
    }
    else
    {
	cmd = 0;
    }

    return (cmd);
}