1
2
3
4
5
6
7
8
9
export const getNextDir = (grammar, index) => {
if (index >= grammar.length - 1) return false;
if (grammar[index + 1] == "^") return "UP";
if (grammar[index + 1] == "V") return "DOWN";
if (grammar[index + 1] == "<") return "LEFT";
if (grammar[index + 1] == ">") return "RIGHT";
if (grammar[index + 1] == "]") return false;
return false;
};