-
Notifications
You must be signed in to change notification settings - Fork 9
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
evaluator: Add expression evaluation for basic types #37
Conversation
Rename evalExpressions to evalExprList so that it more closely aligns with the newly implemented expression parser.
Add expression evaluation for basic types, including arithmetic operations, logical operations, comparison operations, string concatenations, unary operators and grouping with (). Still outstanding are all array and map operations.
firebase-deployment: https://evy-lang--37-s5dh163y.web.app (23e4336) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🥗
} | ||
case *Bool: | ||
if op == parser.OP_BANG { | ||
return &Bool{Val: !right.Val} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this use boolVal()
like the comparison operators? Otherwise this creates a new Bool value and is not one of TRUE
or FALSE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i see in a later PR you get rid of TRUE/FALSE, so this doesn't matter.
Add index and dot expression evaluation in evaluator, similar to binary expression evaluation. Change Array.Elements and Map.Order to pointer. This is another preparatory step for proper array and map manipulation so that two variables may reference the same array or map and if one gets updated the other one will get updated too. Rework scoped Value updates such that instead of replacing the value in the scope on assignment with scope.set(name, newValue), we now update the Value field with scope.get(name).Set(newValue) --- The first three commits are covered by PRs #37 and #38 . This merges the following commits: * parser: Fix IndexExpression.Type() for indexed string * parser: Fix missing early return on index error * evaluator: Rework scoped Value updates * evaluator: Change Array.Elements and Map.Order to pointer * evaluator: Add index and dot expression evaluation * evaluator Rename local variable for consistency pkg/evaluator/builtin.go | 2 +- pkg/evaluator/evaluator.go | 100 +++++++++++++++++------- pkg/evaluator/evaluator_test.go | 87 ++++++++++++++++++++- pkg/evaluator/scope.go | 10 --- pkg/evaluator/value.go | 131 +++++++++++++++++++++++++++----- pkg/parser/expression.go | 9 ++- pkg/parser/expression_test.go | 4 + pkg/parser/parser_test.go | 4 + 8 files changed, 286 insertions(+), 61 deletions(-) Pull-Request: #39
Add expression evaluation for basic types, including arithmetic operations,
logical operations, comparison operations, string concatenations, unary
operators and grouping with (). Still outstanding are all array and map
operations.