diff --git a/bare.sh b/bare.sh index de81394109e4d58b3a5558f3205f86a740367c1c..7964d32796b526e6b3edf715cee14337cd760f22 100755 --- a/bare.sh +++ b/bare.sh @@ -497,7 +497,6 @@ read_block() { # Check if we can exit the block if [ "$depth" -lt 0 ]; then next_line # consume "end;" - interpreter_debug "Finished block section, consuming target '$pattern'" return 0 elif [ "$depth" -le 0 ] && echo "$block_line" | grep "$pattern" >/dev/null; then # Don't consume custom targets @@ -553,6 +552,7 @@ interpret() { while test_predicate "$predicate"; do call_self "$path" done + interpret && return ;; "if "*) path="$(get_block_name "if")" @@ -582,11 +582,13 @@ interpret() { done # Delete last generated executable if it's blank [ -z "$(cat "$path")" ] && rm "$path" + interpret && return ;; "function "*) name="$(echo "$line" | trim_line | sed 's/function \(.*\) do/\1/')" [ -z "$name" ] && interpreter_die "Invalid function name '$name'" read_block > "$FULL_PATH/$name.$EXTENSION" + interpret && return ;; "set "*) set_var "$(echo "$line" | nth_arg 2)" "$(evaluate_format "$(echo "$line" | nth_arg 3-)")" @@ -614,7 +616,7 @@ interpret() { # Start if [ "$TIME_EXECUTION" -eq 0 ]; then interpret - debug "Done" + interpreter_debug "Done" else start="$(get_millis)" interpret diff --git a/example.bb b/example.bb new file mode 100644 index 0000000000000000000000000000000000000000..7052a690e827038f4b054a883179d56b7fab48d5 --- /dev/null +++ b/example.bb @@ -0,0 +1,10 @@ +clear X; +incr X; +incr X; +incr X; + +while X not 0 do; + decr X; +end; + +debug X; \ No newline at end of file diff --git a/example2.bb b/example2.bb new file mode 100644 index 0000000000000000000000000000000000000000..f16db743087fc69fad35d85e359878c436d26b2f --- /dev/null +++ b/example2.bb @@ -0,0 +1,25 @@ +clear X; +incr X; +incr X; +clear Y; +incr Y; +incr Y; +incr Y; +clear Z; +while X not 0 do; + clear W; + while Y not 0 do; + incr Z; + incr W; + decr Y; + end; + while W not 0 do; + incr Y; + decr W; + end; + decr X; +end; + +debug X; +debug Y; +debug Z; \ No newline at end of file