-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
It looks like binary shift operations are supposed to be supported, but here is a very simple test case that fails:
test('leftshift', () {
const evaluator = ExpressionEvaluator();
final expression = Expression.parse("2 << 3");
expect(evaluator.eval(expression, {}), 16);
});Here is the eexception I get:
Instance of 'ParserException': end of input expected (at 1:3)
package:petitparser/src/core/result.dart 56:22 Failure.value
package:expressions/src/expressions.dart 32:62 Expression.parse
I have done some investigations and it seems like this has something to do with the order in which the operators are defined. (best guess is that they are matched in order of definition so the first match, single <, 'wins'.) If I change the order of the elements in the binaryOperations definition is seems to work, but I'm not sure if this breaks something else when the precedence is out of order now:
static const Map<String, int> binaryOperations = {
'??': 0,
'||': 1,
'&&': 2,
'|': 3,
'^': 4,
'&': 5,
'==': 6,
'!=': 6,
'<=': 7,
'>=': 7,
'<<': 8,
'>>': 8,
'<': 7,
'>': 7,
'+': 9,
'-': 9,
'*': 10,
'/': 10,
'%': 10,
'~/': 10,
};Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels