Warning: session_start(): open(/var/lib/php/sessions/sess_b975smd5r6ueps4kutf61p04lc, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
// TODO: unary operators
sclass ShuntingYardCore {
new L operatorStack;
void handleEOT() {
while (nempty(operatorStack)) {
var o = popLast(operatorStack);
assertNequals(o, "(");
outputQueue.add(o);
}
}
void handleToken(S token) {
if (iTok >= l(tok)) {
false;
}
S t = tok.get(iTok);
bool op = isOperator(t), space = isSpacer(t);
if (op && space) warn("Operators should not be spacers");
if (eq(t, "(")) {
finishLiteral();
operatorStack.add(t);
} else if (eq(t, ")")) {
finishLiteral();
while (!eq(last(operatorStack), "(")) {
assertNempty(operatorStack);
outputQueue.add(popLast(operatorStack));
}
popLast(operatorStack);
} else if (op) {
finishLiteral();
S o1 = t, o2;
while (!eqOneOf(o2 = last(operatorStack), "(", null)
&& (precedence(o2) > precedence(o1)
|| precedence(o2) == precedence(o1) && isLeftAssociative(o1))) {
ifdef ShuntingYardParser_debug
print("popLast");
endifdef
outputQueue.add(popLast(operatorStack));
}
operatorStack.add(o1);
}
true;
}
// return 0 for non-operator
int precedence(Op op) {
ret 1;
}
swappable bool isLeftAssociative(Op op) { true; }
}