From ec6ca08d18f159759bfc1ec00499394f7a1d4a07 Mon Sep 17 00:00:00 2001 From: DrMaxNix Date: Thu, 8 Sep 2022 21:33:52 +0200 Subject: [PATCH] :memo: rename `function` to `command` --- doc/concept.sh | 18 +++++++++--------- src/parser.js | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/concept.sh b/doc/concept.sh index 6e48cea..f575134 100644 --- a/doc/concept.sh +++ b/doc/concept.sh @@ -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 diff --git a/src/parser.js b/src/parser.js index 419909d..228ed97 100644 --- a/src/parser.js +++ b/src/parser.js @@ -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");