Pushdown Automaton in java