-
Notifications
You must be signed in to change notification settings - Fork 7
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
parser: Update eventHandler parsing for parameters and bare return #70
Conversation
3a7a5d1
to
9f5d315
Compare
firebase-deployment: https://evy-lang--70-nrwpfmke.web.app (63feee0) |
8a25888
to
f0fd036
Compare
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
Sorry it took me so long to get to this.
print "func x" | ||
end | ||
for x := range 10 | ||
print "x" x |
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.
nit: there's a mixture of 4-space indent and tab indent in the evy fragments throughout this file. This change adds more mixture (one of each). Maybe a trivial cleanup of it all later?
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.
🍍 Perhaps ignore this for now since it may be painful to restack all your other PRs - this is my only comment and it's just a nit
Add variable validation in for statements. In specific, variable declared in the as `for VAR := range ...` should follow the same validation rules as other variable declarations. It's been an oversight.
Use validateVarDecl in parameters rather than duplicating the validation for the sake of slightly more accurate error messages.
Update eventHandler parsing for parameters and bare return. In follow up commits we will add valid builtin eventHandler names and signatures and add evaluation.
Validate eventHandlers against builtin names and parameters, such that `on unknown_event` errors and eventhandlers with wrong types of parameters also error. It is valid to drop all parameters in the source if they aren't used.
Wire eventHandler to frontend so that when `on <event>` block appears in evy code the corresponding frontend event triggers the execution of that block. Currently implemented events: `down`, `up`, `move`, `key`. Only `frontend:` and `all:` commits are relevant, the `parser:` commits are covered in #70 Sample code https://evy-lang--73-51oq7tbx.web.app#draw on down x:num y:num print "down" x y end on up print "up" end on key c:string print "key" c end simple drawing tool d := false width 1 on down x:num y:num d = true move x y end on up d = false end on move x:num y:num if d line x y end end This merges the following commits: * frontend: Add memToString and stringToMem * frontend: Unify naming and add comments * frontend: Optionally load evy source via URL fragment * frontend: Refactor canvas scale parameters * all: Implement up, down, move and key events frontend/index.js | 125 ++++++++++++++++++++++++++++++++----- frontend/samples/dot.evy | 18 ++++++ frontend/samples/draw.evy | 17 +++++ pkg/evaluator/evaluator.go | 51 +++++++++++++-- pkg/evaluator/value.go | 25 ++++++++ pkg/parser/parser.go | 8 +-- pkg/wasm/main.go | 78 +++++++++++++++++++++-- 7 files changed, 292 insertions(+), 30 deletions(-) Pull-Request: #73
Update eventHandler parsing for parameters and bare return. Add builtin
eventHandler declarations for known even names and parameters.
In preparation fix for loop variable declaration validation and unify
parameter declaration validation with variable declaration validation.
This is part one of a two part PR. The second Part will add evaluation and
wiring with frontend.