Compare commits

...

2 commits

Author SHA1 Message Date
76cd248697
parse/code,constants,functions
All checks were successful
/ job (push) Successful in 4m56s
2025-07-04 07:44:31 +02:00
531fcacbe7
constants/regex 2025-07-04 06:14:08 +02:00

View file

@ -49,7 +49,7 @@ rwx_main() {
# source user root
rwx_source "${RWX_SELF_USER}"
# parse code cache
rwx_parse
rwx_parse_code
# context / command
if [ -n "${RWX_COMMAND_NAME}" ]; then
"${RWX_SELF_COMMAND}${RWX_COMMAND_NAME}" "${@}"
@ -163,30 +163,30 @@ rwx_find_shell() {
# │ main │ parse │
# ╰──────┴───────╯
rwx_parse() {
local ws="[[:space:]]*"
local start="^${ws}"
local constant="[_A-Z][_0-9A-Z]*"
local setting="=.*"
local func="${ws}(${ws})${ws}{.*"
local id="[_a-zA-Z][_a-z0-9A-Z]*"
local line
RWX_CONSTANTS=""
RWX_REGEX_CONSTANT="[_A-Z][_0-9A-Z]*"
RWX_REGEX_FUNCTION="[_A-Za-z][_0-9A-Za-z]*"
RWX_REGEX_SET="=.*"
RWX_REGEX_SPACES="[[:space:]]*"
RWX_REGEX_BEGIN="^${RWX_REGEX_SPACES}"
RWX_REGEX_OPEN="\
${RWX_REGEX_SPACES}(${RWX_REGEX_SPACES})${RWX_REGEX_SPACES}{.*"
rwx_parse_code() {
# parse constants
RWX_CONSTANTS="$(rwx_parse_constants)"
# parse functions
RWX_FUNCTIONS="$(rwx_parse_functions)"
}
rwx_parse_constants() {
printf "%s\n" "${RWX_CODE}" |
grep "${start}${constant}${setting}" |
sed "s|${start}\\(${constant}\\)${setting}|\\1|" |
while IFS= read -r line; do
RWX_CONSTANTS="${RWX_CONSTANTS}${line}
"
done
RWX_FUNCTIONS=""
grep "${RWX_REGEX_BEGIN}${RWX_REGEX_CONSTANT}${RWX_REGEX_SET}" |
sed "s|${RWX_REGEX_BEGIN}\\(${RWX_REGEX_CONSTANT}\\)${RWX_REGEX_SET}|\\1|"
}
rwx_parse_functions() {
printf "%s\n" "${RWX_CODE}" |
grep "${start}${id}${func}" |
sed "s|${start}\\(${id}\\)${func}|\\1|" |
while IFS= read -r line; do
RWX_FUNCTIONS="${RWX_FUNCTIONS}${line}
"
done
grep "${RWX_REGEX_BEGIN}${RWX_REGEX_FUNCTION}${RWX_REGEX_OPEN}" |
sed "s|${RWX_REGEX_BEGIN}\\(${RWX_REGEX_FUNCTION}\\)${RWX_REGEX_OPEN}|\\1|"
}
# ╭──────┬─────╮