0
0

📝 rename function to command

This commit is contained in:
DrMaxNix 2022-09-08 21:33:52 +02:00
parent 5cb7408ee7
commit ec6ca08d18
2 changed files with 12 additions and 12 deletions

View File

@ -158,24 +158,24 @@ pxl|pixel|canv|canvas draw
## FUNCTIONS ##
# - functions have their own scopes
# - they can call other functions
## OWN COMMANDS ##
# - command definitions have their own scopes
# - they can call other commands
# - their own vars are private
# - they can't acces root-scope's vars (except they were made global using `glob`)
# - args are copied into local scope
# - args with &-prefix modify corresponding var in global scope
# the function scope "myfunction1" starts here
# the command scope "mycommand1" starts here
# argument $1 is readonly; $2 is read/write; $3 and $4 are optional and will default to `null`
def myfunction1 $1 &$2 ($3 $4)
def mycommand1 $1 &$2 ($3 $4)
# current function scope ends here
# current command scope ends here
end
# call a function called "myfunction1"
# call a command called "mycommand1"
# arg $1 = 42; arg $2 = $test (returned to parent scope)
myfunction1 42 $test
mycommand1 42 $test
@ -183,7 +183,7 @@ myfunction1 42 $test
# halt the program
halt
# return from function to parent scope
# return from command to parent scope
# halt program in root scope
exit|return|end

View File

@ -55,7 +55,7 @@ class Juicescript_parser {
break;
// FUNCTION DEFINITION //
// OWN COMMAND DEFINITION //
case Juicescript.token_type.DEF:
this.parse_def();
break;
@ -82,7 +82,7 @@ class Juicescript_parser {
}
/*
PARSER: Handle function definition
PARSER: Handle own command definition
*/
parse_def(){
let parameter_list = [];
@ -128,7 +128,7 @@ class Juicescript_parser {
}
/*
PARSER: Handle function definition
PARSER: Handle `end` command
*/
parse_end(){
/**/this.debug("enter scope root");