Re: Artikel Debian

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//char expr [] = "(a(((+bc(d))l+ll)de(faaa)))zzz";
char expr [] = "abc*de[f,g]hijk";
int i = 0;
int j;
int state1 [1024];
int state2 [1024];
char statechar [1024];

char gettoken () {
    return expr [i++];
}
void tokenback () {
    i--;
}

/*
aaaa
aaaaaa
aaaaaaa
aaaaaaaa()
*/

int stream ();
int followed ();
int compound ();
int or_operator ();
int repeat_operator ();

int or_operator () {
    int j1, j2, j3;
    int t;

    if (gettoken () == '[') {
        j3 = j;
        j++;
        j1 = repeat_operator ();
        if (gettoken () != ',') {
            fprintf (stderr, "Komma vergessen");
            exit (1);
        }
        j2 = repeat_operator ();
        if (gettoken () != ']') {
            fprintf (stderr, "Klammer vergessen ]");
            exit (1);
        }
        state1 [j3] = j1;
        state2 [j3] = j2;
        statechar [j3] = '#';
        j3 = repeat_operator ();
        state1 [j1] = j3;
        state2 [j1] = j3;
        state1 [j2] = j3;
        state2 [j2] = j3;
    }
    else {
        tokenback ();
        j3 = repeat_operator ();
    }
return j3;
}

int repeat_operator () {
    int j1;

    if (gettoken () == '*') {
        j1 = stream (j);
    }
    else {
        tokenback ();
        j1 = stream (-1);
    }
return j1;
}

int stream (int jin) {
    compound ();
    return followed (jin);
}

int followed (int jin) {
    int j1, j2;
    int t;

    int ch = gettoken ();
    if ((ch >= 'a') \&amp;\&amp; (ch <= 'z')) {
        t = j;
        j++;
        if (jin == -1)
            j2 = j1 = or_operator ();
        else {
            j1 = or_operator ();
            j2 = t;
        }
        state1 [t] = j1;
        state2 [t] = j2;
        statechar [t] = ch;
    }
    else
        tokenback ();
return t;
}

int compound () {
    if (gettoken () == '(') {
        or_operator ();
        if (gettoken () != ')') {
            fprintf (stderr, "fehler klammer vergessen %c %in", expr [i], i);
            exit (1);
        }
    }
    else
        tokenback ();
}




int main (void) {
    int k;
    or_operator (0);

    for (k = 0;  k < 24;  k++) {
        printf ("statechar [%i] = %cn", k, statechar [k]);
        printf ("state1 [%i] = %in", k, state1 [k]);
        printf ("state2 [%i] = %in", k, state2 [k]);
    }

}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define X   1024
#define Y   1024
#define END -1

int state1 [Y][X][2];
int state2 [Y][X][2];
int statechar [Y][X];
int x;
int y;

int states () {
    int k, l;

    for (k = 0;  k < Y;  k++)
        for (l = 0;  l < X;  l++)
            state1 [k][l][0] = state2 [k][l][0] = state1 [k][l][1] = state2 [k][l][1] = statechar [k][l] = END;
}

int jx = 0;

//char expr [] = "abc*de[fasd,asddsr]qdsda*ghijk";
char expr [] = "ab[c,d]efghijk";
int i = 0;

char gettoken () {
    return expr [i++];
}
void tokenback () {
    i--;
}

/*
aaaa
aaaaaa
aaaaaaa
aaaaaaaa()
*/

int stream ();
int followed ();
int compound ();
int or_operator ();
int repeat_operator ();

int or_operator () {
    if (gettoken () == '[') {
        state1 [y][x][0] = x+1;
        state1 [y][x][1] = y+1;
        x++;
        y++;
        repeat_operator ();
        if (gettoken () != ',') {
            fprintf (stderr, "Komma vergessen");
            exit (1);
        }
        state1 [y][x][0] = x+1;
        state1 [y][x][1] = y+1;
        x++;
        y++;
        repeat_operator ();
        if (gettoken () != ']') {
            fprintf (stderr, "Klammer vergessen ]");
            exit (1);
        }
        repeat_operator ();
    }
    else {
        tokenback ();
        repeat_operator ();
    }

}


int repeat_operator () {
    if (gettoken () == '*') {
        stream ();
    }
    else {
        tokenback ();
        stream ();
    }

}

int stream () {
    compound ();
    followed ();
}

int followed () {
    int ch = gettoken ();
    int st, xtmp;
    if ((ch >= 'a') \&amp;\&amp; (ch <= 'z')) {
        printf ("%c ", ch);
        state1 [y][x][0] = y;
        state1 [y][x][1] = x+1;
        state2 [y][x][0] = y;
        state2 [y][x][1] = x+1;
        statechar [y][x] = ch;
        x = x+1;
        or_operator ();
        printf ("%in", x);

    }
    else
        tokenback ();
}

int compound () {
    if (gettoken () == '(') {
        or_operator ();
        if (gettoken () != ')') {
            fprintf (stderr, "fehler klammer vergessen %c %in", expr [i], i);
            exit (1);
        }
    }
    else
        tokenback ();
}




int main (void) {
    int k, l;
    or_operator (0);
    for (k = 0;  k < 10;  k++) {
        printf ("state1[0][%i][x] = %i, state1[0][%i][y] = %i ", k, state1[0][k][0], k, state1[0][k][1]);
        printf ("state2[0][%i][x] = %i, state2[0][%i][y] = %i ", k, state2[0][k][0], k, state2[0][k][1]);
        printf ("statechar[0][%i] = %cn", k, statechar[0][k]);
    }

    for (l = 0;  l < 10;  l++) {
        for (k = 0;  k < 10;  k++)
            printf ("(%2i,%2i,%2i,%2i) ", state1[l][k][0], state1[l][k][1], state2[l][k][0], state2[l][k][1]);
        printf ("n");
    }


}

state1[0][0][x] = 0, state1[0][0][y] = 1 state2[0][0][x] = 0, state2[0][0][y] = 1 statechar[0][0] = a
state1[0][1][x] = 0, state1[0][1][y] = 2 state2[0][1][x] = 0, state2[0][1][y] = 2 statechar[0][1] = b
state1[0][2][x] = 3, state1[0][2][y] = 1 state2[0][2][x] = 0, state2[0][2][y] = 0 statechar[0][2] =
state1[0][3][x] = 0, state1[0][3][y] = 0 state2[0][3][x] = 0, state2[0][3][y] = 0 statechar[0][3] =
state1[0][4][x] = 0, state1[0][4][y] = 0 state2[0][4][x] = 0, state2[0][4][y] = 0 statechar[0][4] =
state1[0][5][x] = 0, state1[0][5][y] = 0 state2[0][5][x] = 0, state2[0][5][y] = 0 statechar[0][5] =
state1[0][6][x] = 0, state1[0][6][y] = 0 state2[0][6][x] = 0, state2[0][6][y] = 0 statechar[0][6] =
state1[0][7][x] = 0, state1[0][7][y] = 0 state2[0][7][x] = 0, state2[0][7][y] = 0 statechar[0][7] =
state1[0][8][x] = 0, state1[0][8][y] = 0 state2[0][8][x] = 0, state2[0][8][y] = 0 statechar[0][8] =
state1[0][9][x] = 0, state1[0][9][y] = 0 state2[0][9][x] = 0, state2[0][9][y] = 0 statechar[0][9] =
( 0, 1, 0, 1) ( 0, 2, 0, 2) ( 3, 1, 0, 0) ( 0, 0, 0, 0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