Next: , Previous: , Up: Executive Assembler Introduction   [Index]


8.1.3 Program Parsing And Execution

The second and last program execution scope of the standalone interpreter parses the procedural aime program and executes it.

See Procedural Language Interpreter.

See Procedural Language Interpreter Usage Outline.

See Standalone Context.

static int
set_logic(struct context_type *context_data, const char *program,
	  const void *data)
{
    int status;

Declare the parsing context, the error recorded and the program executable representation hook:

    struct x1f4_a1_type a1;
    struct x1f4_a1record_type a1record;
    unsigned flags;
    void *proGram;

See struct x1f4_a1_type.

See struct x1f4_a1record_type.

Set up the parsing context. Many of the required objects are recorded with the assembled executive objects set. The x1f4_xset_shuffle sets up most of the parsing content from the set.

See struct x1f4_indexset_type.

    x1f4_xset_shuffle(&a1, &flags, context_data->indexset_data);

See x1f4_xset_shuffle.

    a1.bcollect_set.a1record_data = &a1record;

Instruct the program parser to observe the features set up after x1f4_xset_shuffle and to optimize the program:

    flags |= X1f4_A1_BCOLLECT | X1f4_A1_OPTIMIZE;

Parse the program, construct its executable representation:

See x1f4_init_shuffle.

    context_data->line = NULL;
    status = x1f4_init_shuffle(&proGram, data, flags, &a1);
    if (status) {

Parsing failed, examine the error:

See Procedural Language Interpreter Errors.

	if (status == X1f4_A1_ALLOC_ERROR) {
	    perror(context_data->self);
	} else {

Describe the parse error:

	    fprintf(stderr, "%s: cannot parse ", context_data->self);
	    if (program) {
		fprintf(stderr, "`%s'", program);
	    } else {
		fprintf(stderr, "program");
	    }
	    fprintf(stderr, "\n");
	    fprintf(stderr, "%s: ", context_data->self);
	    a1record.pick = 1;
	    x1f4_stat_shuffle
		(stderr, test_cast, data, &a1record,
		 &context_data->indexset_data->eelookup_set.eelookup);
	    fprintf(stderr, "\n");
	}
    } else {

See x1f4_look_indexset.

Enroll the temporaries tracker into the function call observing schema:

See Procedural Temporaries.

See e4ll Temporaries Disposal Usage Example.

	status = x1f4_pipe_e4ll
	    (context_data->indexset_data->autodeck_set.less, proGram);
	if (status) {
	    perror(context_data->self);
	} else {
	    X1f4_E4_C_MODE degree;

See x1f4_pipe_e4ll.

Reset the temporaries indicator:

	    context_data->class = 0;

Reset the "error reported" flag:

	    context_data->error = 0;

Set the exit value, may be changed by a call to the exit function:

	    context_data->exit = 0;

Set the source location retriever (used by error reporters):

See Miscellaneous Convenience Routines.

	    context_data->line = pick_shuffle;

	    context_data->logic = proGram;

Make the temporaries indicator available for signal handlers:

	    static_class = &context_data->class;

Execute the program, disposing temporaries and collecting the result (of main evaluation):

	    status = x1f4_long_shuffle
		(proGram, &context_data->class, context_data, flat_text,
		 &degree);

See x1f4_long_shuffle.

The 2nd, 3rd and 4th arguments describe the set up temporaries disposer. The 5th is the address where the return of the executed program main will be stored.

See The Resource Management.

	    if (status) {

The program execution failed, see whether exit was called:

		if (context_data->exit) {
		    status = context_data->exit >> 1;
		} else {

Describe the error:

See The Error Reporters.

		    flush_error(context_data, program);
		}
	    } else {

Set function return to the executed program main return:

		status = degree;
	    }
	}

Destroy the executable representation when done:

	x1f4_fini_shuffle(&proGram);
    }

    return status;
}

Next: Assembling The Executive, Previous: Program Interpretation, Up: Executive Assembler Introduction   [Index]