Exemplo n.º 1
0
/*
 * Read a declaration up to a semicolon or an open curly brace and add it to <declaration>.
 */
static int handle_declaration(FILE *fp, Buffer *declaration)
{
    int c;

    while ((c = fgetc(fp)) != EOF) {
        if (c == ';') {
            bufAddC(declaration, c);
            break;
        }
        else if (c == '{') {
            Buffer body = { 0 };
            handle_compound(fp, &body);
            bufReset(&body);
            break;
        }
        else if (c == '/') {
            bufAddC(declaration, c);
            handle_comment(fp, declaration);
        }
        else if (c == '"' || c == '\'') {
            handle_string(fp, declaration, c);
        }
        else {
            bufAddC(declaration, c);
        }
    }

    return 0;
}
Exemplo n.º 2
0
/*
 * Read a compound statement and add it to <buffer>.
 */
static int handle_compound(FILE *fp, Buffer *buffer)
{
    int c;

    while ((c = fgetc(fp)) != EOF) {
        bufAddC(buffer, c);

        if (c == '}')
            break;
        else if (c == '"' || c == '\'')
            handle_string(fp, buffer, c);
        else if (c == '{')
            handle_compound(fp, buffer);
        else if (c == '/') {
            bufAddC(buffer, c);
            handle_comment(fp, buffer);
        }
    }

    return 0;
}
Exemplo n.º 3
0
/**
 * Handles the signal.
 *
 * This procedure identifies the signal abstraction and then calls either
 * the compound signal handler, or the operation signal handler procedure.
 *
 * @param p0 the internal memory
 * @param p1 the knowledge memory
 * @param p2 the knowledge memory count
 * @param p3 the knowledge memory size
 * @param p4 the signal memory
 * @param p5 the signal memory count
 * @param p6 the signal memory size
 * @param p7 the shutdown flag
 * @param p8 the signal memory interrupt request flag
 * @param p9 the signal memory mutex
 * @param p10 the abstraction
 * @param p11 the abstraction count
 * @param p12 the model / signal
 * @param p13 the model / signal count
 * @param p14 the details / parameters
 * @param p15 the details / parameters count
 * @param p16 the priority (Hand over as reference!)
 * @param p17 the signal identification (Hand over as reference!)
 * @param p18 the direct execution flag
 */
void handle(void* p0, void* p1, void* p2, void* p3, void* p4, void* p5, void* p6,
    void* p7, void* p8, void* p9, void* p10, void* p11,
    void* p12, void* p13,  void* p14, void* p15, void* p16, void* p17, void* p18) {

    log_terminated_message((void*) INFORMATION_LEVEL_LOG_MODEL, (void*) L"Handle signal.");

    // The comparison result.
    int r = *NUMBER_0_INTEGER_MEMORY_MODEL;

/*??
    fwprintf(stdout, L"TEST handle ac: %i\n", p11);
    fwprintf(stdout, L"TEST handle *ac: %i\n", *((int*) p11));
    fwprintf(stdout, L"TEST handle a: %i\n", p10);
    fwprintf(stdout, L"TEST handle *a: %ls\n", (wchar_t*) p10);
*/

    if (r == *NUMBER_0_INTEGER_MEMORY_MODEL) {

        // CAUTION! Do NOT remove this section with "COMPOUND_MEMORY_ABSTRACTION"!
        // It is needed for at least initial startup logic residing in CYBOL
        // files only, before any logic is created and contained as runtime
        // knowledge models in the knowledge memory.
        compare_equal_arrays((void*) &r, p10, p11, (void*) COMPOUND_MEMORY_ABSTRACTION, (void*) COMPOUND_MEMORY_ABSTRACTION_COUNT, (void*) WIDE_CHARACTER_PRIMITIVE_MEMORY_ABSTRACTION);

        if (r != *NUMBER_0_INTEGER_MEMORY_MODEL) {

            handle_compound(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p12, p13, p16, p17, p18);
        }
    }

    if (r == *NUMBER_0_INTEGER_MEMORY_MODEL) {

        compare_equal_arrays((void*) &r, p10, p11, (void*) ENCAPSULATED_KNOWLEDGE_PATH_MEMORY_ABSTRACTION, (void*) ENCAPSULATED_KNOWLEDGE_PATH_MEMORY_ABSTRACTION_COUNT, (void*) WIDE_CHARACTER_PRIMITIVE_MEMORY_ABSTRACTION);

        if (r != *NUMBER_0_INTEGER_MEMORY_MODEL) {

            handle_encapsulated(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p12, p13, p16, p17, p18);
        }
    }

    if (r == *NUMBER_0_INTEGER_MEMORY_MODEL) {

        compare_equal_arrays((void*) &r, p10, p11, (void*) KNOWLEDGE_PATH_MEMORY_ABSTRACTION, (void*) KNOWLEDGE_PATH_MEMORY_ABSTRACTION_COUNT, (void*) WIDE_CHARACTER_PRIMITIVE_MEMORY_ABSTRACTION);

        if (r != *NUMBER_0_INTEGER_MEMORY_MODEL) {

            handle_knowledge(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p12, p13, p16, p17, p18);
        }
    }

    if (r == *NUMBER_0_INTEGER_MEMORY_MODEL) {

        compare_equal_arrays((void*) &r, p10, p11, (void*) OPERATION_MEMORY_ABSTRACTION, (void*) OPERATION_MEMORY_ABSTRACTION_COUNT, (void*) WIDE_CHARACTER_PRIMITIVE_MEMORY_ABSTRACTION);

        if (r != *NUMBER_0_INTEGER_MEMORY_MODEL) {

            handle_operation(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p12, p13, p14, p15, p16, p17);
        }
    }

    if (r == *NUMBER_0_INTEGER_MEMORY_MODEL) {

        log_message((void*) WARNING_LEVEL_LOG_MODEL, (void*) COULD_NOT_HANDLE_SIGNAL_THE_SIGNAL_ABSTRACTION_IS_UNKNOWN_MESSAGE_LOG_MODEL, (void*) COULD_NOT_HANDLE_SIGNAL_THE_SIGNAL_ABSTRACTION_IS_UNKNOWN_MESSAGE_LOG_MODEL_COUNT);
    }
}
/**
 * Handles an encapsulated logic.
 *
 * @param p0 the internal memory
 * @param p1 the knowledge memory
 * @param p2 the knowledge memory count
 * @param p3 the knowledge memory size
 * @param p4 the signal memory
 * @param p5 the signal memory count
 * @param p6 the signal memory size
 * @param p7 the shutdown flag
 * @param p8 the signal memory interrupt request flag
 * @param p9 the signal memory mutex
 * @param p10 the model / signal
 * @param p11 the model / signal count
 * @param p12 the priority (Hand over as reference!)
 * @param p13 the signal identification (Hand over as reference!)
 * @param p14 the direct execution flag
 */
void handle_encapsulated(void* p0, void* p1, void* p2, void* p3, void* p4, void* p5, void* p6,
    void* p7, void* p8, void* p9, void* p10, void* p11, void* p12, void* p13,  void* p14) {

    log_terminated_message((void*) INFORMATION_LEVEL_LOG_MODEL, (void*) L"Handle encapsulated.");

    // The encapsulated logic name, abstraction, model, details.
    void** eln = NULL_POINTER_MEMORY_MODEL;
    void** elnc = NULL_POINTER_MEMORY_MODEL;
    void** elns = NULL_POINTER_MEMORY_MODEL;
    void** ela = NULL_POINTER_MEMORY_MODEL;
    void** elac = NULL_POINTER_MEMORY_MODEL;
    void** elas = NULL_POINTER_MEMORY_MODEL;
    void** elm = NULL_POINTER_MEMORY_MODEL;
    void** elmc = NULL_POINTER_MEMORY_MODEL;
    void** elms = NULL_POINTER_MEMORY_MODEL;
    void** eld = NULL_POINTER_MEMORY_MODEL;
    void** eldc = NULL_POINTER_MEMORY_MODEL;
    void** elds = NULL_POINTER_MEMORY_MODEL;
    // The logic name, abstraction, model, details.
    void** ln = NULL_POINTER_MEMORY_MODEL;
    void** lnc = NULL_POINTER_MEMORY_MODEL;
    void** lns = NULL_POINTER_MEMORY_MODEL;
    void** la = NULL_POINTER_MEMORY_MODEL;
    void** lac = NULL_POINTER_MEMORY_MODEL;
    void** las = NULL_POINTER_MEMORY_MODEL;
    void** lm = NULL_POINTER_MEMORY_MODEL;
    void** lmc = NULL_POINTER_MEMORY_MODEL;
    void** lms = NULL_POINTER_MEMORY_MODEL;
    void** ld = NULL_POINTER_MEMORY_MODEL;
    void** ldc = NULL_POINTER_MEMORY_MODEL;
    void** lds = NULL_POINTER_MEMORY_MODEL;

    // Get compound logic element as double-encapsulated model.
    //
    // CAUTION!
    // The abstraction of an encapsulated name must always be "character".
    // The details are uninteresting, since an encapsulated name cannot have
    // constraints. That is, only the model is of interest. It contains the
    // hierarchical name of the knowledge part to be retrieved.
    //
    // Example of a model pointing to another model containing a logic name:
    // model="application.record.logic_name"
    //
    // The knowledge root does not have a details container with meta
    // information, which is why a null pointer is handed over here twice.
    //
    // Compare also with procedure "get_universal_compound_element_by_name"
    // in source file "executor/accessor/getter/compound_getter.c"!
    get_compound_element_by_name(p1, p2, *NULL_POINTER_MEMORY_MODEL, *NULL_POINTER_MEMORY_MODEL,
        p10, p11,
        (void*) &eln, (void*) &elnc, (void*) &elns,
        (void*) &ela, (void*) &elac, (void*) &elas,
        (void*) &elm, (void*) &elmc, (void*) &elms,
        (void*) &eld, (void*) &eldc, (void*) &elds);

    // The knowledge root does not have a details container with meta
    // information, which is why a null pointer is handed over here twice.
    get_compound_element_by_name(p1, p2, *NULL_POINTER_MEMORY_MODEL, *NULL_POINTER_MEMORY_MODEL,
        *elm, *elmc,
        (void*) &ln, (void*) &lnc, (void*) &lns,
        (void*) &la, (void*) &lac, (void*) &las,
        (void*) &lm, (void*) &lmc, (void*) &lms,
        (void*) &ld, (void*) &ldc, (void*) &lds);

    // The comparison result.
    int r = *NUMBER_0_INTEGER_MEMORY_MODEL;

    if (r == *NUMBER_0_INTEGER_MEMORY_MODEL) {

        compare_equal_arrays((void*) &r, *la, *lac, (void*) COMPOUND_MEMORY_ABSTRACTION, (void*) COMPOUND_MEMORY_ABSTRACTION_COUNT, (void*) WIDE_CHARACTER_PRIMITIVE_MEMORY_ABSTRACTION);

        if (r != *NUMBER_0_INTEGER_MEMORY_MODEL) {

            handle_compound(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, *lm, *lmc, p12, p13, p14);
        }
    }

    if (r == *NUMBER_0_INTEGER_MEMORY_MODEL) {

        compare_equal_arrays((void*) &r, *la, *lac, (void*) OPERATION_MEMORY_ABSTRACTION, (void*) OPERATION_MEMORY_ABSTRACTION_COUNT, (void*) WIDE_CHARACTER_PRIMITIVE_MEMORY_ABSTRACTION);

        if (r != *NUMBER_0_INTEGER_MEMORY_MODEL) {

            handle_operation(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, *lm, *lmc, *ld, *ldc, p12, p13);
        }
    }
}