cache/variables
This commit is contained in:
parent
7c65fb2e25
commit
1d6a7bab9b
2 changed files with 35 additions and 4 deletions
21
sh/main.sh
21
sh/main.sh
|
@ -172,17 +172,23 @@ 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_VARIABLE="[_a-z][_0-9a-z]*"
|
||||
|
||||
RWX_REGEX_BEGIN="^${RWX_REGEX_SPACES}"
|
||||
RWX_REGEX_BEGIN="^"
|
||||
RWX_REGEX_OPEN="\
|
||||
${RWX_REGEX_SPACES}(${RWX_REGEX_SPACES})${RWX_REGEX_SPACES}{.*"
|
||||
|
||||
RWX_REGEX_TARGET_CONSTANT="\
|
||||
${RWX_REGEX_BEGIN}\\(${RWX_REGEX_CONSTANT}\\)${RWX_REGEX_SET}"
|
||||
RWX_REGEX_TARGET_DOC="\
|
||||
${RWX_REGEX_BEGIN}# \\(.*\\)${RWX_REGEX_SPACES}\$"
|
||||
${RWX_REGEX_BEGIN}${RWX_REGEX_SPACES}# \\(.*\\)${RWX_REGEX_SPACES}\$"
|
||||
RWX_REGEX_TARGET_FUNCTION="\
|
||||
${RWX_REGEX_BEGIN}\\(${RWX_REGEX_FUNCTION}\\)${RWX_REGEX_OPEN}"
|
||||
RWX_REGEX_TARGET_VARIABLE="\
|
||||
${RWX_REGEX_BEGIN}\\(${RWX_REGEX_VARIABLE}\\)${RWX_REGEX_SET}"
|
||||
|
||||
# cache for code variables
|
||||
_rwx_code_variables=""
|
||||
|
||||
rwx_parse_code() {
|
||||
# parse aliases
|
||||
|
@ -197,6 +203,8 @@ EOF
|
|||
RWX_CONSTANTS="$(rwx_parse_constants)"
|
||||
# parse functions
|
||||
RWX_FUNCTIONS="$(rwx_parse_functions)"
|
||||
# parse variables
|
||||
_rwx_code_variables="$(rwx_parse_variables)"
|
||||
}
|
||||
rwx_parse_aliases() {
|
||||
printf "%s" "${_rwx_code}" |
|
||||
|
@ -205,18 +213,23 @@ rwx_parse_aliases() {
|
|||
--file "${RWX_AWK}"
|
||||
}
|
||||
rwx_parse_constants() {
|
||||
printf "%s\n" "${_rwx_code}" |
|
||||
printf "%s" "${_rwx_code}" |
|
||||
sed --silent "s|${RWX_REGEX_TARGET_CONSTANT}|\\1|p"
|
||||
}
|
||||
rwx_parse_functions() {
|
||||
printf "%s\n" "${_rwx_code}" |
|
||||
printf "%s" "${_rwx_code}" |
|
||||
sed --silent "s|${RWX_REGEX_TARGET_FUNCTION}|\\1|p"
|
||||
}
|
||||
rwx_parse_variables() {
|
||||
printf "%s" "${_rwx_code}" |
|
||||
sed --silent "s|${RWX_REGEX_TARGET_VARIABLE}|\\1|p"
|
||||
}
|
||||
|
||||
# ╭──────┬──────╮
|
||||
# │ main │ test │
|
||||
# ╰──────┴──────╯
|
||||
|
||||
#= rt
|
||||
rwx_test() {
|
||||
local item
|
||||
# TODO CODE
|
||||
|
|
18
sh/self.sh
18
sh/self.sh
|
@ -7,12 +7,30 @@ rwx_code() {
|
|||
echo "${_rwx_code}"
|
||||
}
|
||||
|
||||
# show the cached aliases
|
||||
#= rca
|
||||
rwx_code_aliases() {
|
||||
echo "${RWX_ALIASES}"
|
||||
}
|
||||
|
||||
# show the cached constants
|
||||
#= rcc
|
||||
rwx_code_constants() {
|
||||
echo "${RWX_CONSTANTS}"
|
||||
}
|
||||
|
||||
# show the cached functions
|
||||
#= rcf
|
||||
rwx_code_functions() {
|
||||
echo "${RWX_FUNCTIONS}"
|
||||
}
|
||||
|
||||
# show the cached variables
|
||||
#= rcv
|
||||
rwx_code_variables() {
|
||||
echo "${_rwx_code_variables}"
|
||||
}
|
||||
|
||||
# meta doc
|
||||
#= rd
|
||||
rwx_doc() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue