#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char expr [] = "(a(((bc(d))lll)de(faaa)))zzz";
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 () {
repeat_operator ();
if (gettoken () == '+') {
repeat_operator ();
}
else
tokenback ();
}
int repeat_operator () {
if (gettoken () == '*') {
stream ();
}
else
tokenback ();
stream ();
}
int stream () {
compound ();
followed ();
}
int followed () {
int ch = gettoken ();
if ((ch >= 'a') \&\& (ch <= 'z')) {
printf ("%c ", ch);
or_operator ();
}
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) {
or_operator ();
}