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

Add arguments to custom actions #48

Merged
merged 44 commits into from
Feb 24, 2024
Merged

Add arguments to custom actions #48

merged 44 commits into from
Feb 24, 2024

Conversation

electrikmilk
Copy link
Owner

This refactors custom actions to allow for argument definitions that can then be used later to pass arguments to the defined action.

This makes the following syntax possible:

action add(number op1, number op2) {
    const add_expression = op1 + op2
    output("{add_expression}")
}

const result = add(2,2)
show("{result}")

I'm not crazy about this because it introduces syntax that does not translate directly to shortcuts but having this functionality is very important to users of the language and the prospect of a standard library of custom actions is very interesting to me.

This is a second pass at parsing custom actions but also improves it by
automatically skipping comments.
This creates the header required for the desired scoped stack.

This implements that as well as listing the available functions and
their declared arguments and pastes the defined body.
This allows us to not have to keep track of variables in a separate
parsing loop.

This also just makes the code for generating custom action calls a lot
cleaner.
@electrikmilk electrikmilk added the enhancement New feature or request label Feb 24, 2024
@electrikmilk electrikmilk self-assigned this Feb 24, 2024
@electrikmilk electrikmilk merged commit a698feb into main Feb 24, 2024
2 checks passed
@electrikmilk electrikmilk deleted the custom-actions-redux branch March 17, 2024 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor custom actions to accept arguments and behave more like functions
1 participant