Operatoren + und * hinzugefügt in Aufgabe1_Kellerautomat
This commit is contained in:
@@ -48,7 +48,7 @@ public class Aufgabe1_Kellerautomat {
|
||||
break;
|
||||
case 2:
|
||||
symbol = wordChars.remove(0);
|
||||
if (symbol == 'O' && stackSymbol == 'Z') {
|
||||
if (isOperator(symbol) && stackSymbol == 'Z') {
|
||||
state = 3;
|
||||
} else if (symbol == 'Z' && stackSymbol == 'Z') {
|
||||
stack.add('Z');
|
||||
@@ -79,7 +79,7 @@ public class Aufgabe1_Kellerautomat {
|
||||
stack.add('Z');
|
||||
stack.add('Z');
|
||||
state = 2;
|
||||
} else if (symbol == 'O' && stackSymbol == 'Z') {
|
||||
} else if (isOperator(symbol) && stackSymbol == 'Z') {
|
||||
state = 3;
|
||||
} else {
|
||||
dontAccept(word);
|
||||
@@ -121,4 +121,8 @@ public class Aufgabe1_Kellerautomat {
|
||||
System.out.println("Word: " + word + "\naccepted ");
|
||||
}
|
||||
|
||||
private static boolean isOperator(char symbol){
|
||||
return symbol == '+' || symbol == '*';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user