You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying a simple expression as follows but it keeps throwing errors -
`
void example_2() {
// Parse expression:
var expression = Expression.parse("person.name='John'");
var context = {'person': Person('Jane')};
final evaluator = const MyEvaluator();
var r = evaluator.eval(expression, context);
}
class Person {
String name;
Person(this.name);
Map<String, dynamic> toJson() => {'name': name};
}
class MyEvaluator extends ExpressionEvaluator {
const MyEvaluator(); @OverRide
dynamic evalMemberExpression(
MemberExpression expression, Map<String, dynamic> context) {
var object = eval(expression.object, context).toJson();
return object[expression.property.name];
}
} The exception I get is as follows - Unhandled exception:
end of input expected at 1:12
#0 Failure.value (package:petitparser/src/context/failure.dart:13:18) #1 Expression.parse (package:expressions/src/expressions.dart:32:55) #2 example_2 (file:///Users/khurrammahmood/StudioProjects/expressions/example/expressions_example.dart:29:31) #3 main (file:///Users/khurrammahmood/StudioProjects/expressions/example/expressions_example.dart:6:3) #4 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:283:19) #5 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
`
The text was updated successfully, but these errors were encountered:
I was trying a simple expression as follows but it keeps throwing errors -
`
void example_2() {
// Parse expression:
var expression = Expression.parse("person.name='John'");
var context = {'person': Person('Jane')};
final evaluator = const MyEvaluator();
var r = evaluator.eval(expression, context);
}
class Person {
String name;
Person(this.name);
Map<String, dynamic> toJson() => {'name': name};
}
class MyEvaluator extends ExpressionEvaluator {
const MyEvaluator();
@OverRide
dynamic evalMemberExpression(
MemberExpression expression, Map<String, dynamic> context) {
var object = eval(expression.object, context).toJson();
return object[expression.property.name];
}
}
The exception I get is as follows -
Unhandled exception:end of input expected at 1:12
#0 Failure.value (package:petitparser/src/context/failure.dart:13:18)
#1 Expression.parse (package:expressions/src/expressions.dart:32:55)
#2 example_2 (file:///Users/khurrammahmood/StudioProjects/expressions/example/expressions_example.dart:29:31)
#3 main (file:///Users/khurrammahmood/StudioProjects/expressions/example/expressions_example.dart:6:3)
#4 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:283:19)
#5 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
`
The text was updated successfully, but these errors were encountered: