Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle assignment expressions #20

Closed
kmahmood74 opened this issue Dec 11, 2021 · 1 comment
Closed

Handle assignment expressions #20

kmahmood74 opened this issue Dec 11, 2021 · 1 comment

Comments

@kmahmood74
Copy link

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)

`

@rbellens
Copy link
Contributor

Assignments are not supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants