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

go: Add if statement parsing and evaluation #21

Merged
merged 3 commits into from
Sep 16, 2022
Merged

go: Add if statement parsing and evaluation #21

merged 3 commits into from
Sep 16, 2022

Conversation

juliaogris
Copy link
Member

Add if statement parsing and evaluation - this is a pretty straight
forward PR, with only minor refactors around BlockStatment parsing and
bool constants during evaluation.

@github-actions
Copy link

github-actions bot commented Sep 15, 2022

Visit the preview URL for this PR (updated for commit d19c380):

https://evy-lang--pr21-if-z6wg59s0.web.app

(expires Fri, 23 Sep 2022 06:28:31 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

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.

some comments to keep you going.

pkg/parser/ast.go Outdated Show resolved Hide resolved
pkg/parser/ast.go Show resolved Hide resolved
pkg/evaluator/evaluator.go Outdated Show resolved Hide resolved
pkg/evaluator/evaluator.go Outdated Show resolved Hide resolved
pkg/parser/parser.go Show resolved Hide resolved
pkg/parser/parser.go Outdated Show resolved Hide resolved
Update output for end of line for readability from `<end of line>` to
simply `end of line`. In the context of error messages the latter seems
to read nicer.
Parse `if` statements into If AST node. While at it, abstract the way we
create block statements with a configurable set of terminating tokens.
`else` for example is terminating for if statements, but not for
function bodies, else bodies or loop bodies.

Also update block statement parsing, to NOT parse past the END token so
we can read and validate the block end token from the call site.
Add if statement evaluation to evaluator. Add bool constants TRUE, FALSE
for easier comparison. Update index.html in frontend for code that
evaluates, we don't yet parse and evaluate expressions.
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

@juliaogris juliaogris merged commit c6909d3 into master Sep 16, 2022
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