; where $1 is the word being parsed.
if ($left($1,1) == %) {
; this is a variable.
if ($mid($1,2,1) == !) {
; this might be a variable name OR it might be a delayed evaluation.
if ($var($1,1).local) {
; %!variable is a literal local variable name, so let's evaluate it without delay.
; (compatibility mode)
return $eval($1,2)
}
elseif ($var($regsubex($1,/^%\K!+/,),1).local) {
; %variable (without !'s) is a known local variable, so let's delay evaluation
; by removing just one '!' from $1 (eg: from %!!!variable to %!!variable) (new mode)
return $regsubex($1,/^%\K!/,)
}
elseif ($var($1,1).global) {
; %!variable is a literal global variable name, so let's evaluate it without
; delay. (compatibility mode)
return $eval($1,2)
}
; else { ; since no known (local or global) variables exist by this name
; (eg: %!!!variable) then let's treat it as a delayed evaluation. (new mode)
return $regsubex($1,/^%\K!/,)
; }
}
; this is just a variable name without '!'. so try to evaluate it. (as usual)
return $eval($1,2)
}