-
Notifications
You must be signed in to change notification settings - Fork 0
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
UDF Parse Define #1
Comments
CREATE FUNCTION function_name ([params]) RETURN type_spec FROM create_function_from_vendor; function_param
: name_label type_spec {
$$ = new FunctionParam($1, $2->type);
}
;
function_param_list
: function_param {
$$ = new FunctionParamList();
$$->addParam($1);
}
| function_param_list COMMA function_param {
$$ = $1;
$$->addParam($3);
}
;
create_function_from_vendor
: HTTP_URL {
$$ = new FunctionSource(std::string("HTTP"), *$1);
}
| WASM_BASE64 {
$$ = new FunctionSource(std::string("WASM"), *$1);
}
;
create_function_sentence
: KW_CREATE KW_FUNCTION opt_if_not_exists name_label L_PAREN R_PAREN KW_RETURN type_spec KW_FROM create_function_from_vendor {
$$ = new CreateFunctionSentence($4, new FunctionParamList(), $8->type, $10, $3);
}
| KW_CREATE KW_FUNCTION opt_if_not_exists name_label L_PAREN function_param_list R_PAREN KW_RETURN type_spec KW_FROM create_function_from_vendor {
$$ = new CreateFunctionSentence($4, $6, $9->type, $11, $3);
}
; |
Can we make this? CREATE FUNCTION [FUNCTION NAME](x [TYPE], y [TYPE]) RETURNS [TYPE] FROM WASM://[base64];
CREATE FUNCTION [FUNCTION NAME](x [TYPE], y [TYPE]) RETURNS [TYPE] FROM WAT://[base64];
CREATE FUNCTION [FUNCTION NAME](x [TYPE], y [TYPE]) RETURNS [TYPE] FROM PATH://[HTTP Path Or File Path]; |
A greatest common divider example: CREATE FUNCTION gcd_main(x INT32, y INT32) RETURN INT32 FROM WAT://KG1vZHVsZQogIChmdW5jICRnY2QgKHBhcmFtIGkzMiBpMzIpIChyZXN1bHQgaTMyKQogICAgKGxvY2FsIGkzMikKICAgIGJsb2NrICA7OyBsYWJlbCA9IEAxCiAgICAgIGJsb2NrICA7OyBsYWJlbCA9IEAyCiAgICAgICAgbG9jYWwuZ2V0IDAKICAgICAgICBicl9pZiAwICg7QDI7KQogICAgICAgIGxvY2FsLmdldCAxCiAgICAgICAgbG9jYWwuc2V0IDIKICAgICAgICBiciAxICg7QDE7KQogICAgICBlbmQKICAgICAgbG9vcCAgOzsgbGFiZWwgPSBAMgogICAgICAgIGxvY2FsLmdldCAxCiAgICAgICAgbG9jYWwuZ2V0IDAKICAgICAgICBsb2NhbC50ZWUgMgogICAgICAgIGkzMi5yZW1fdQogICAgICAgIGxvY2FsLnNldCAwCiAgICAgICAgbG9jYWwuZ2V0IDIKICAgICAgICBsb2NhbC5zZXQgMQogICAgICAgIGxvY2FsLmdldCAwCiAgICAgICAgYnJfaWYgMCAoO0AyOykKICAgICAgZW5kCiAgICBlbmQKICAgIGxvY2FsLmdldCAyCiAgKQogIChleHBvcnQgIm1haW4iIChmdW5jICRnY2QpKSA7OyBleHBvcnQgd2l0aCBtYWluCik=;
RETURN UDF("gcd", [12, 27]);
DROP FUNCTION gcd; |
great work. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
created by base64
Example:
Wasm Raw Wat
The text was updated successfully, but these errors were encountered: