Fix some binding powers

This commit is contained in:
Tangent Wantwight 2024-05-18 23:15:46 -04:00
parent 2770a2de3b
commit 2b6aff0dab

View file

@ -77,13 +77,13 @@ const Operators: TokenHandler[] = [
leftBindingPower: -1,
token: MINUS_TOKEN,
parse: (left, matched, parser) =>
map(parser.parseSubExpression(0), (right) => ({value: -right})),
map(parser.parseSubExpression(99), (right) => ({value: -right})),
},
makeInfixOp(PLUS_TOKEN, 10, 11, (left, right) => ({ value: left + right })),
makeInfixOp(MINUS_TOKEN, 10, 11, (left, right) => ({ value: left - right })),
makeInfixOp(TIMES_TOKEN, 10, 11, (left, right) => ({ value: left * right })),
makeInfixOp(FLOOR_TOKEN, 10, 11, (left, right) => ({ value: Math.floor(left / right) })),
makeInfixOp(DIV_TOKEN, 10, 11, (left, right) => ({ value: left / right })),
makeInfixOp(TIMES_TOKEN, 20, 21, (left, right) => ({ value: left * right })),
makeInfixOp(FLOOR_TOKEN, 20, 21, (left, right) => ({ value: Math.floor(left / right) })),
makeInfixOp(DIV_TOKEN, 20, 21, (left, right) => ({ value: left / right })),
];
const ZERO = { value: 0 };