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

evaluator: Add map and array literals #38

Merged
merged 1 commit into from
Oct 19, 2022
Merged

evaluator: Add map and array literals #38

merged 1 commit into from
Oct 19, 2022

Conversation

juliaogris
Copy link
Member

Add map and array literals to evaluation. We should have done this a
while back. Oversight.


Only the last commit is relevant of this PR, It depends on #37 to be
merged first (too many conflicts).

@github-actions
Copy link

github-actions bot commented Oct 17, 2022

firebase-deployment: https://evy-lang--38-kypt33yb.web.app (3e0a252)

Copy link
Contributor

@camh- camh- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🍀

Add map and array literals. We should have done this a while back.
Oversight.
@juliaogris juliaogris merged commit 344d2e1 into master Oct 19, 2022
@juliaogris juliaogris deleted the eval-arraylit branch October 19, 2022 22:26
juliaogris added a commit that referenced this pull request Oct 19, 2022
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
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

Successfully merging this pull request may close these issues.

None yet

2 participants